mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Only allow &optional
in records
There was some confusing behavior with &optional and locals, so this should get rid of that by making it an error. However, there is a case where function parameters are still allowed to have &optional - this is because there are checks for &default in parameters as well.
This commit is contained in:
parent
a2680d5eca
commit
4e5a56c5e0
4 changed files with 19 additions and 4 deletions
|
@ -297,10 +297,10 @@ bool Attributes::CheckAttr(Attr* a) {
|
|||
case ATTR_IS_USED: break;
|
||||
|
||||
case ATTR_OPTIONAL:
|
||||
if ( global_var )
|
||||
return AttrError("&optional is not valid for global variables");
|
||||
if ( ! in_record )
|
||||
return AttrError("&optional is only valid for record fields");
|
||||
|
||||
if ( in_record && Find(ATTR_DEFAULT) )
|
||||
if ( Find(ATTR_DEFAULT) )
|
||||
return AttrError("Using &default and &optional together results in &default behavior");
|
||||
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue