summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-expr.cpp
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-11-30 17:09:52 -0500
committerGitHub <noreply@github.com>2021-11-30 17:09:52 -0500
commitd10ca980c3d84e4838272f2082e8e35f3a7e50c0 (patch)
tree626da0eef8e81487630bf3e3e190374d9b0ae77d /source/slang/slang-check-expr.cpp
parentce12e1d64d6b0b62609f061d3773a7e8b35849c3 (diff)
Fix issue around constant folding/bool (#2036)
* #include an absolute path didn't work - because paths were taken to always be relative. * Fix bool handling in constant folding for generic parameters.
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
-rw-r--r--source/slang/slang-check-expr.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp
index 6b1ab13cc..e8384e0ab 100644
--- a/source/slang/slang-check-expr.cpp
+++ b/source/slang/slang-check-expr.cpp
@@ -871,6 +871,13 @@ namespace Slang
return getIntVal(intLitExpr);
}
+ if (auto boolLitExpr = expr.as<BoolLiteralExpr>())
+ {
+ // If it's a boolean, we allow promotion to int.
+ const IntegerLiteralValue value = IntegerLiteralValue(boolLitExpr.getExpr()->value);
+ return m_astBuilder->create<ConstantIntVal>(value);
+ }
+
// it is possible that we are referring to a generic value param
if (auto declRefExpr = expr.as<DeclRefExpr>())
{