diff --git a/hilti/toolchain/include/ast/declarations/module-uid.h b/hilti/toolchain/include/ast/declarations/module-uid.h index ea767191c..ad825df8a 100644 --- a/hilti/toolchain/include/ast/declarations/module-uid.h +++ b/hilti/toolchain/include/ast/declarations/module-uid.h @@ -64,7 +64,8 @@ struct UID { in_memory(true) { assert(this->id && ! parse_extension.empty() && ! process_extension.empty()); // just make up a path - path = util::fmt("/tmp/hilti/%s.%" PRIu64 ".%s.%s", id, ++_no_file_counter, process_extension, parse_extension); + path = util::fmt("/tmp/hilti/%s.%" PRIu64 ".%s.%s", unique, ++_no_file_counter, process_extension, + parse_extension); } UID(const UID& other) = default; @@ -73,7 +74,8 @@ struct UID { /** Hashes the UID. */ size_t hash() const { - return rt::hashCombine(std::hash{}(id.str()), std::hash{}(path.native()), + return rt::hashCombine(std::hash{}(id.str()), std::hash{}(unique.str()), + std::hash{}(path.native()), std::hash{}(parse_extension.native()), std::hash{}(process_extension.native())); } @@ -82,14 +84,14 @@ struct UID { UID& operator=(UID&& other) = default; bool operator==(const UID& other) const { - return id == other.id && path == other.path && parse_extension == other.parse_extension && - process_extension == other.process_extension; + return std::tie(id, unique, path, parse_extension, process_extension) == + std::tie(other.id, other.unique, other.path, other.parse_extension, other.process_extension); } bool operator!=(const UID& other) const { return ! (*this == other); } bool operator<(const UID& other) const { - return std::make_tuple(id, path, parse_extension, process_extension) < - std::make_tuple(other.id, other.path, other.parse_extension, other.process_extension); + return std::tie(id, unique, path, parse_extension, process_extension) < + std::tie(other.id, other.unique, other.path, other.parse_extension, other.process_extension); } /** Returns the module's globally uniqued name. */ diff --git a/tests/hilti/ast/imported-twice.hlt b/tests/hilti/ast/imported-twice.hlt new file mode 100644 index 000000000..ef5457306 --- /dev/null +++ b/tests/hilti/ast/imported-twice.hlt @@ -0,0 +1,7 @@ +# @TEST-DOC: Test that we handle the same module declared twice fine, regression test for #1813. +# +# @TEST-EXEC: hiltic -dj %INPUT %INPUT +# @TEST-EXEC: hiltic -dj %INPUT $(basename %INPUT) +# @TEST-EXEC: hiltic -dj $(basename %INPUT) %INPUT + +module foo {}