summaryrefslogtreecommitdiff
path: root/source/slang/slang-ast-type.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ast-type.cpp')
-rw-r--r--source/slang/slang-ast-type.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp
index 840aa4a67..af4f6d124 100644
--- a/source/slang/slang-ast-type.cpp
+++ b/source/slang/slang-ast-type.cpp
@@ -19,7 +19,14 @@ Type* Type::_createCanonicalTypeOverride()
Val* Type::_substituteImplOverride(ASTBuilder* astBuilder, SubstitutionSet subst, int* ioDiff)
{
int diff = 0;
- auto canSubst = getCanonicalType()->substituteImpl(astBuilder, subst, &diff);
+ auto canonicalType = getCanonicalType();
+
+ // If canonicalType is identical to this, then we shouldn't try to call
+ // canonicalType->substituteImpl because that would lead to infinite recursion.
+ if (canonicalType == this)
+ return this;
+
+ auto canSubst = canonicalType->substituteImpl(astBuilder, subst, &diff);
// If nothing changed, then don't drop any sugar that is applied
if (!diff)