mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/bbannier/issue-3279'
* origin/topic/bbannier/issue-3279:
Fix handling of module scope when checking exported Spicy types for collisions
(cherry picked from commit 30dc6af831
)
This commit is contained in:
parent
b6090f1fe6
commit
651b208937
2 changed files with 21 additions and 1 deletions
|
@ -215,7 +215,7 @@ void Manager::registerPacketAnalyzer(const std::string& name, const std::string&
|
||||||
void Manager::registerType(const std::string& id, const TypePtr& type) {
|
void Manager::registerType(const std::string& id, const TypePtr& type) {
|
||||||
auto [ns, local] = parseID(id);
|
auto [ns, local] = parseID(id);
|
||||||
|
|
||||||
if ( const auto& old = detail::lookup_ID(local.c_str(), ns.c_str()) ) {
|
if ( const auto& old = detail::lookup_ID(local.c_str(), ns.c_str(), true) ) {
|
||||||
// This is most likely to trigger for IDs that other Spicy modules
|
// This is most likely to trigger for IDs that other Spicy modules
|
||||||
// register. If we two Spicy modules need the same type, that's ok as
|
// register. If we two Spicy modules need the same type, that's ok as
|
||||||
// long as they match.
|
// long as they match.
|
||||||
|
|
20
testing/btest/spicy/export-type-collision-with-global.spicy
Normal file
20
testing/btest/spicy/export-type-collision-with-global.spicy
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# @TEST-REQUIRES: have-spicy
|
||||||
|
#
|
||||||
|
# @TEST-EXEC: spicyz -d -o foo.hlto foo.spicy foo.evt
|
||||||
|
# @TEST-EXEC: zeek -NN Zeek::Spicy foo.hlto >output1 2>&1
|
||||||
|
# @TEST-EXEC: ZEEK_SPICY_MODULE_PATH=$PWD zeek -B all -NN Zeek::Spicy >output2 2>&1
|
||||||
|
# @TEST-EXEC: diff output1 output2 1>&2
|
||||||
|
#
|
||||||
|
# @TEST-DOC: This validates that an exported Spicy name with local part identical with a Zeek name in global scope does not clash. Regression test for #3279.
|
||||||
|
|
||||||
|
# @TEST-START-FILE foo.spicy
|
||||||
|
module foo;
|
||||||
|
|
||||||
|
# `foo::Direction` has the same local part as Zeek's `::Direction`.
|
||||||
|
public type Direction = enum { a };
|
||||||
|
public type Other = enum { a };
|
||||||
|
# @TEST-END-FILE
|
||||||
|
|
||||||
|
# @TEST-START-FILE foo.evt
|
||||||
|
import foo;
|
||||||
|
# @TEST-END-FILE
|
Loading…
Add table
Add a link
Reference in a new issue