summaryrefslogtreecommitdiffstats
path: root/source/slang/check.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-08 18:13:53 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-08 18:22:26 -0700
commit767d47a842700653b8deffe82ccb3c85ad582c13 (patch)
tree5eaa7eaab892504db53cca4b8044b0c8bcde58b3 /source/slang/check.cpp
parent5c864cbd58ea7cca6bec7b1f023422e27f0bcb1f (diff)
Fix constant folding for `ParenExpr`
Adding an explicit AST node for `(expr)` was a good change, but it broke constant folding because I forgot to handle it.
Diffstat (limited to 'source/slang/check.cpp')
-rw-r--r--source/slang/check.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp
index 2b9abef90..b87f7c6bc 100644
--- a/source/slang/check.cpp
+++ b/source/slang/check.cpp
@@ -2128,6 +2128,12 @@ namespace Slang
RefPtr<IntVal> TryConstantFoldExpr(
ExpressionSyntaxNode* expr)
{
+ // Unwrap any "identity" expressions
+ while (auto parenExpr = dynamic_cast<ParenExpr*>(expr))
+ {
+ expr = parenExpr->base;
+ }
+
// TODO(tfoley): more serious constant folding here
if (auto constExp = dynamic_cast<ConstantExpressionSyntaxNode*>(expr))
{