mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Fixing attributes to allow &default in tables/sets to be associated
with the field. This works now: type X: record { a: table[string] of bool &default=table( ["foo"] = T ); b: table[string] of bool &default=table(); c: set[string] &default=set("A", "B", "C"); d: set[string] &default=set(); }; I think previously the intend was to associate &default with the table/set (i.e., define the default value for non-existing indices). However, that was already not working: the error checking was reporting type mismatches. So, this shouldn't break anything and make things more consistent.
This commit is contained in:
parent
68a30a0b5a
commit
0a97a9e82a
10 changed files with 72 additions and 24 deletions
|
@ -100,6 +100,7 @@ extern Expr* g_curr_debug_expr;
|
|||
|
||||
Expr* bro_this = 0;
|
||||
int in_init = 0;
|
||||
int in_record = 0;
|
||||
bool in_debug = false;
|
||||
bool resolving_global_ID = false;
|
||||
|
||||
|
@ -704,10 +705,10 @@ type:
|
|||
$$ = new SetType($3, 0);
|
||||
}
|
||||
|
||||
| TOK_RECORD '{' type_decl_list '}'
|
||||
| TOK_RECORD '{' { ++in_record; } type_decl_list { --in_record; } '}'
|
||||
{
|
||||
set_location(@1, @4);
|
||||
$$ = new RecordType($3);
|
||||
set_location(@1, @5);
|
||||
$$ = new RecordType($4);
|
||||
}
|
||||
|
||||
| TOK_UNION '{' type_list '}'
|
||||
|
@ -805,7 +806,7 @@ type_decl:
|
|||
TOK_ID ':' type opt_attr ';'
|
||||
{
|
||||
set_location(@1, @5);
|
||||
$$ = new TypeDecl($3, $1, $4);
|
||||
$$ = new TypeDecl($3, $1, $4, (in_record > 0));
|
||||
}
|
||||
;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue