From 17c7163c2ae8fc290e70b43d8700b68ef18b1ee1 Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 6 Oct 2023 14:03:18 -0700 Subject: Small type system fixes. (#3265) --- source/slang/slang-check-expr.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (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 05a6ed249..22bc2cae8 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -372,7 +372,24 @@ namespace Slang { expr->type.isLeftValue = false; } - + else + { + // If we are accessing a readonly property, then the result + // is not an l-value. + if (auto propertyDecl = as(declRef.getDecl())) + { + bool isLValue = false; + for (auto member : propertyDecl->members) + { + if (as(member) || as< RefAccessorDecl>(member)) + { + isLValue = true; + break; + } + } + expr->type.isLeftValue = isLValue; + } + } return expr; } } @@ -3322,7 +3339,10 @@ namespace Slang // A swizzle can be used as an l-value as long as there // were no duplicates in the list of components - swizExpr->type.isLeftValue = !anyDuplicates; + swizExpr->type.isLeftValue = !anyDuplicates && + swizExpr->base && + swizExpr->base->type && + swizExpr->base->type.isLeftValue; return swizExpr; } -- cgit v1.2.3