mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
bug fixes for using "when" in functions that have a local of type "any"
This commit is contained in:
parent
cfe6616de1
commit
b86d5b4424
5 changed files with 32 additions and 2 deletions
|
@ -1615,7 +1615,12 @@ bool same_type(const BroType* t1, const BroType* t2, bool is_init, bool match_re
|
|||
}
|
||||
|
||||
case TYPE_TYPE:
|
||||
return same_type(t1, t2, is_init, match_record_field_names);
|
||||
{
|
||||
auto tt1 = t1->AsTypeType();
|
||||
auto tt2 = t2->AsTypeType();
|
||||
return same_type(tt1->Type(), tt1->Type(),
|
||||
is_init, match_record_field_names);
|
||||
}
|
||||
|
||||
case TYPE_UNION:
|
||||
reporter->Error("union type in same_type()");
|
||||
|
|
|
@ -507,6 +507,7 @@ public:
|
|||
TypeType* ShallowClone() override { return new TypeType(type); }
|
||||
|
||||
BroType* Type() { return type.get(); }
|
||||
const BroType* Type() const { return type.get(); }
|
||||
|
||||
protected:
|
||||
IntrusivePtr<BroType> type;
|
||||
|
|
|
@ -136,6 +136,10 @@ IntrusivePtr<Val> Val::DoClone(CloneState* state)
|
|||
return {NewRef{}, this};
|
||||
}
|
||||
|
||||
if ( type->Tag() == TYPE_TYPE )
|
||||
// These are immutable, essentially.
|
||||
return {NewRef{}, this};
|
||||
|
||||
// Fall-through.
|
||||
|
||||
default:
|
||||
|
|
1
testing/btest/Baseline/language.any-when/out
Normal file
1
testing/btest/Baseline/language.any-when/out
Normal file
|
@ -0,0 +1 @@
|
|||
9
|
19
testing/btest/language/any-when.zeek
Normal file
19
testing/btest/language/any-when.zeek
Normal file
|
@ -0,0 +1,19 @@
|
|||
# @TEST-EXEC: zeek -b %INPUT >out
|
||||
# @TEST-EXEC: btest-diff out
|
||||
|
||||
type c: count;
|
||||
function foo(): count
|
||||
{
|
||||
local bar: any;
|
||||
bar = c;
|
||||
return when ( 5 > 3 )
|
||||
{
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
when ( local b = foo() )
|
||||
print b;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue