From afb1405bf7974d714cee10fcce0c61fe28cd075d Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 27 Sep 2024 17:11:07 -0700 Subject: Fix l-value computation for subscript call. (#5177) --- source/slang/slang-check-expr.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source/slang/slang-check-expr.cpp') diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 1b9725a8c..bdf8721e9 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -436,6 +436,26 @@ namespace Slang // of a GLSL buffer interface block which isn't marked as // read_only expr->type.isLeftValue = isMutableGLSLBufferBlockVarExpr(baseExpr) && (expr->type.hasReadOnlyOnTarget == false); + + // Another exception is if we are accessing a property + // that provides a [nonmutating] setter. + if (!expr->type.isLeftValue && + as(declRef.getDecl())) + { + bool isLValue = false; + for (auto member : as(declRef.getDecl())->members) + { + if (as(member) || as< RefAccessorDecl>(member)) + { + if (member->findModifier()) + { + isLValue = true; + } + break; + } + } + expr->type.isLeftValue = isLValue; + } } else { -- cgit v1.2.3