mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
fix & regression test for GH-3839 (spurious warnings for "when" constructs)
This commit is contained in:
parent
cb88f6316c
commit
e960c29acb
2 changed files with 8 additions and 1 deletions
|
@ -434,7 +434,7 @@ ValPtr ScriptFunc::Invoke(zeek::Args* args, Frame* parent) const {
|
||||||
|
|
||||||
// Warn if the function returns something, but we returned from
|
// Warn if the function returns something, but we returned from
|
||||||
// the function without an explicit return, or without a value.
|
// the function without an explicit return, or without a value.
|
||||||
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != TYPE_VOID &&
|
else if ( GetType()->Yield() && GetType()->Yield()->Tag() != TYPE_VOID && ! GetType()->ExpressionlessReturnOkay() &&
|
||||||
(flow != FLOW_RETURN /* we fell off the end */ || ! result /* explicit return with no result */) &&
|
(flow != FLOW_RETURN /* we fell off the end */ || ! result /* explicit return with no result */) &&
|
||||||
! f->HasDelayed() )
|
! f->HasDelayed() )
|
||||||
reporter->Warning("non-void function returning without a value: %s", Name());
|
reporter->Warning("non-void function returning without a value: %s", Name());
|
||||||
|
|
|
@ -26,6 +26,13 @@ event zeek_init()
|
||||||
when [h] ( local hname3 = lookup_addr(h) ) {}
|
when [h] ( local hname3 = lookup_addr(h) ) {}
|
||||||
timeout to + 2sec {}
|
timeout to + 2sec {}
|
||||||
|
|
||||||
|
# The following used to generate a spurious warning, so it's here
|
||||||
|
# as a regression test.
|
||||||
|
when ( local res = lookup_addr(127.0.0.1) )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
print "done";
|
print "done";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue