diff --git a/src/spicy/spicyz/glue-compiler.cc b/src/spicy/spicyz/glue-compiler.cc index 6c6120b377..a401d1f856 100644 --- a/src/spicy/spicyz/glue-compiler.cc +++ b/src/spicy/spicyz/glue-compiler.cc @@ -1165,7 +1165,7 @@ bool GlueCompiler::PopulateEvents() { // to a unit now. ev.unit = ev.path.namespace_(); if ( ! ev.unit ) { - hilti::logger().error(hilti::util::fmt("unit type missing in hook '%s'", ev.path)); + hilti::logger().error(hilti::util::fmt("namespace missing for '%s'", ev.path), ev.location); return false; } @@ -1174,7 +1174,7 @@ bool GlueCompiler::PopulateEvents() { ev.hook = ev.path; } else { - hilti::logger().error(hilti::util::fmt("unknown unit type '%s'", ev.unit)); + hilti::logger().error(hilti::util::fmt("no unit type of name '%s'", ev.path), ev.location); return false; } } diff --git a/testing/btest/Baseline/spicy.event-unit-type-fail-2/output b/testing/btest/Baseline/spicy.event-unit-type-fail-2/output new file mode 100644 index 0000000000..7947117e1f --- /dev/null +++ b/testing/btest/Baseline/spicy.event-unit-type-fail-2/output @@ -0,0 +1,3 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +[error] <...>/event-unit-type-fail.evt:5: no unit type of name 'TestAssertion::DoesNotExit' +[error] : aborting after errors diff --git a/testing/btest/Baseline/spicy.event-unit-type-fail-3/output b/testing/btest/Baseline/spicy.event-unit-type-fail-3/output new file mode 100644 index 0000000000..07fecb2a5c --- /dev/null +++ b/testing/btest/Baseline/spicy.event-unit-type-fail-3/output @@ -0,0 +1,3 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +[error] <...>/event-unit-type-fail.evt:5: no unit type of name 'TestAssertion::E' +[error] : aborting after errors diff --git a/testing/btest/Baseline/spicy.event-unit-type-fail/output b/testing/btest/Baseline/spicy.event-unit-type-fail/output new file mode 100644 index 0000000000..5fa94c9936 --- /dev/null +++ b/testing/btest/Baseline/spicy.event-unit-type-fail/output @@ -0,0 +1,3 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. +[error] <...>/event-unit-type-fail.evt:12: namespace missing for 'Data' +[error] : aborting after errors diff --git a/testing/btest/spicy/event-unit-type-fail.evt b/testing/btest/spicy/event-unit-type-fail.evt new file mode 100644 index 0000000000..9f011046b5 --- /dev/null +++ b/testing/btest/spicy/event-unit-type-fail.evt @@ -0,0 +1,38 @@ +# @TEST-REQUIRES: have-spicy +# +# @TEST-EXEC-FAIL: spicyz -d -o test.hlto test.spicy %INPUT 2>output +# @TEST-EXEC: TEST_DIFF_CANONIFIER=diff-remove-abspath btest-diff output +# +# @TEST-DOC: Check that we catch various cases of invalid unit types in event definitions; regression test for #3988. + +protocol analyzer spicy::Test over TCP: + parse with TestAssertion::Data; + +on TestAssertion::Alias -> event Test::my_event(); # works +on Data -> event Test::my_event(); # failure: can't find unit due to missing namespace + +@TEST-START-NEXT + +protocol analyzer spicy::Test over TCP: + parse with TestAssertion::Data; + +on TestAssertion::DoesNotExit -> event Test::my_event(); # failure: no such type + +@TEST-START-NEXT + +protocol analyzer spicy::Test over TCP: + parse with TestAssertion::Data; + +on TestAssertion::E -> event Test::my_event(); # failure: exists, but not a unit type + +@TEST-START-FILE test.spicy +module TestAssertion; + +public type Data = unit { + : uint8; +}; + +public type Alias = Data; +public type E = enum { One }; +@TEST-END-FILE +