Fix function type-equivalence requiring same param names, addresses #957

This commit is contained in:
Jon Siwek 2013-03-07 13:02:33 -06:00
parent 8ee4382721
commit 2293443ea0
4 changed files with 48 additions and 7 deletions

View file

@ -0,0 +1,4 @@
Brogrammers, like bowties, are cool. Brogrammers, like bowties, are cool. Brogrammers, like bowties, are cool.
Brogrammers, like bowties, are cool. Brogrammers, like bowties, are cool.
BROGRAMMERS, LIKE BOWTIES, ARE COOL.
BROGRAMMERS, LIKE BOWTIES, ARE COOL.

View file

@ -0,0 +1,39 @@
# @TEST-EXEC: bro -b %INPUT >out
# @TEST-EXEC: btest-diff out
function double_string(s: string): string
{
return string_cat(s, " ", s);
}
function triple_string(str: string): string
{
return string_cat(str, " ", str, " ", str);
}
type sample_function: record {
s: string;
f: function(str: string): string;
};
event bro_init()
{
local test_sf: sample_function;
test_sf$s = "Brogrammers, like bowties, are cool.";
test_sf$f = triple_string;
print test_sf$f(test_sf$s);
test_sf$f = double_string;
print test_sf$f(test_sf$s);
# Works as expected
test_sf$f = function(str: string): string
{ return to_upper(str); };
print test_sf$f(test_sf$s);
# Func arg names shouldn't factor in to the type check.
test_sf$f = function(s: string): string
{ return to_upper(s); };
print test_sf$f(test_sf$s);
}