From 7740f7905fdebebdbe22011787d432b385f4cd9d Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Tue, 23 Sep 2025 10:12:09 -0500 Subject: fix a crash when using type equality constaint (#8515) Close #8193. When constructing `TransitiveTypeWitness` node, we should check if there is operand that represents two equal times. Currently, we only check whether the operand is `TypeEqualityWitness`, which is not good enough, because a `DeclaredSubtypeWitness` could also be representing two same types, in that case, we should also const fold this kind of witness. Fails to do so, we could finally ends up with a generating a lookup witness IR on a generic parameter that is not supposed to be looked up. --- source/slang/slang-ast-decl-ref.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/slang/slang-ast-decl-ref.cpp') diff --git a/source/slang/slang-ast-decl-ref.cpp b/source/slang/slang-ast-decl-ref.cpp index 7eec32a3a..c054ef994 100644 --- a/source/slang/slang-ast-decl-ref.cpp +++ b/source/slang/slang-ast-decl-ref.cpp @@ -426,6 +426,14 @@ SourceLoc DeclRefBase::getLoc() const return getDecl()->loc; } +// Keep this function here for better debuggin purpose +String DeclRefBase::toString() const +{ + StringBuilder sb; + const_cast(this)->toText(sb); + return sb.produceString(); +} + DeclRefBase* DeclRefBase::getParent() { auto astBuilder = getCurrentASTBuilder(); -- cgit v1.2.3