From e960c29acb9d81da69ced871ab5054c3e2152d3b Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Tue, 23 Jul 2024 15:18:21 -0700 Subject: [PATCH] fix & regression test for GH-3839 (spurious warnings for "when" constructs) --- src/Func.cc | 2 +- testing/btest/language/when.zeek | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Func.cc b/src/Func.cc index 87783a30a9..85d184295d 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -434,7 +434,7 @@ ValPtr ScriptFunc::Invoke(zeek::Args* args, Frame* parent) const { // Warn if the function returns something, but we returned from // 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 */) && ! f->HasDelayed() ) reporter->Warning("non-void function returning without a value: %s", Name()); diff --git a/testing/btest/language/when.zeek b/testing/btest/language/when.zeek index d0d07b44fa..d8a447e8fd 100644 --- a/testing/btest/language/when.zeek +++ b/testing/btest/language/when.zeek @@ -26,6 +26,13 @@ event zeek_init() when [h] ( local hname3 = lookup_addr(h) ) {} 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"; }