summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-check-stmt.cpp4
-rw-r--r--source/slang/slang-diagnostic-defs.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/source/slang/slang-check-stmt.cpp b/source/slang/slang-check-stmt.cpp
index bc89dc94e..a61f48af6 100644
--- a/source/slang/slang-check-stmt.cpp
+++ b/source/slang/slang-check-stmt.cpp
@@ -151,6 +151,10 @@ namespace Slang
Expr* SemanticsVisitor::checkPredicateExpr(Expr* expr)
{
+ if (as<AssignExpr>(expr))
+ {
+ getSink()->diagnose(expr, Diagnostics::assignmentInPredicateExpr);
+ }
Expr* e = expr;
e = CheckTerm(e);
e = coerce(m_astBuilder->getBoolType(), e);
diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h
index 39ceb6678..fed4944d3 100644
--- a/source/slang/slang-diagnostic-defs.h
+++ b/source/slang/slang-diagnostic-defs.h
@@ -277,6 +277,7 @@ DIAGNOSTIC(30053, Error, breakLabelNotFound, "label '$0' used as break target is
DIAGNOSTIC(30054, Error, targetLabelDoesNotMarkBreakableStmt, "invalid break target: statement labeled '$0' is not breakable.")
DIAGNOSTIC(30055, Error, useOfNonShortCircuitingOperatorInDiffFunc, "non-short-circuiting `?:` operator is not allowed in a differentiable function, use `select` instead.")
DIAGNOSTIC(30056, Warning, useOfNonShortCircuitingOperator, "non-short-circuiting `?:` operator is deprecated, use 'select' instead.")
+DIAGNOSTIC(30057, Error, assignmentInPredicateExpr, "use an assignment operation as predicate expression is not allowed, wrap the assignment with '()' to clarify the intent.")
DIAGNOSTIC(30043, Error, getStringHashRequiresStringLiteral, "getStringHash parameter can only accept a string literal")