mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
GH-654: allow table() in function &default expressions
Table parameters of functions previously did not coerce unspecified tables used in their &default attribute to the correct type.
This commit is contained in:
parent
34bf78984b
commit
b698c5507a
3 changed files with 23 additions and 1 deletions
|
@ -1058,7 +1058,7 @@ formal_args_decl:
|
|||
TOK_ID ':' type opt_attr
|
||||
{
|
||||
set_location(@1, @4);
|
||||
$$ = new TypeDecl($3, $1, $4);
|
||||
$$ = new TypeDecl($3, $1, $4, true);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
@ -3,6 +3,19 @@ foo_func, hello
|
|||
bar_func, hmm, hi, 5
|
||||
bar_func, cool, beans, 5
|
||||
bar_func, cool, beans, 13
|
||||
begin table_func, {
|
||||
|
||||
}
|
||||
end table_func, {
|
||||
[the test] = works
|
||||
}
|
||||
begin table_func, {
|
||||
[initial] = conditions
|
||||
}
|
||||
end table_func, {
|
||||
[initial] = conditions,
|
||||
[the test] = works
|
||||
}
|
||||
foo_hook, test
|
||||
foo_hook, hello
|
||||
bar_hook, hmm, hi, 5
|
||||
|
|
|
@ -16,6 +16,13 @@ function bar_func(a: string, b: string &default="hi", c: count &default=5)
|
|||
print "bar_func", a, b, c;
|
||||
}
|
||||
|
||||
function table_func(a: table[string] of string &default=table())
|
||||
{
|
||||
print "begin table_func", a;
|
||||
a["the test"] = "works";
|
||||
print "end table_func", a;
|
||||
}
|
||||
|
||||
### events
|
||||
|
||||
global foo_event: event(a: string &default="hello");
|
||||
|
@ -51,6 +58,8 @@ foo_func();
|
|||
bar_func("hmm");
|
||||
bar_func("cool", "beans");
|
||||
bar_func("cool", "beans", 13);
|
||||
table_func();
|
||||
table_func(table(["initial"] = "conditions"));
|
||||
|
||||
event foo_event("test");
|
||||
event foo_event();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue