From d245c72f2a92a74ccda83f41758c1948ae5132d3 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 24 Aug 2022 10:56:53 -0700 Subject: Compiler time evaluation of all int and bool operators. (#2376) * Compiler time evaluation of all int and bool operators. * Fix linux compile error. * Fix. Co-authored-by: Yong He --- source/slang/slang-ast-type.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-ast-type.cpp') diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp index 664c940a8..a84f04a32 100644 --- a/source/slang/slang-ast-type.cpp +++ b/source/slang/slang-ast-type.cpp @@ -387,15 +387,19 @@ Val* ArrayExpressionType::_substituteImplOverride(ASTBuilder* astBuilder, Substi { int diff = 0; auto elementType = as(baseType->substituteImpl(astBuilder, subst, &diff)); - auto arrlen = as(arrayLength->substituteImpl(astBuilder, subst, &diff)); - SLANG_ASSERT(arrlen); + IntVal* newArrayLength = nullptr; + if (arrayLength) + { + newArrayLength = as(arrayLength->substituteImpl(astBuilder, subst, &diff)); + SLANG_ASSERT(newArrayLength); + } if (diff) { *ioDiff = 1; auto rsType = getArrayType( astBuilder, elementType, - arrlen); + newArrayLength); return rsType; } return this; -- cgit v1.2.3