diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 7972e2d819..7cb0ede2d8 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -1944,6 +1944,13 @@ IntVal* SemanticsVisitor::tryConstantFoldDeclRef( // In HLSL, `const` is used to mark compile-time constant expressions. if (!decl->hasModifier()) return nullptr; + + // The values of specialization constants aren't known at compile time even + // if they're marked `const`. + if (decl->hasModifier() || + decl->hasModifier()) + return nullptr; + if (decl->hasModifier()) { // Extern const is not considered compile-time constant by the front-end.