summaryrefslogtreecommitdiffstats
path: root/source/slang/check.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/check.cpp')
-rw-r--r--source/slang/check.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp
index 4840ae30d..b981fb778 100644
--- a/source/slang/check.cpp
+++ b/source/slang/check.cpp
@@ -3575,6 +3575,32 @@ namespace Slang
decl->SetCheckState(DeclCheckState::CheckedHeader);
+ // If we have a subscript declaration with no accessor declarations,
+ // then we should create a single `GetterDecl` to represent
+ // the implicit meaning of their declaration, so:
+ //
+ // subscript(uint index) -> T;
+ //
+ // becomes:
+ //
+ // subscript(uint index) -> T { get; }
+ //
+
+ bool anyAccessors = false;
+ for(auto accessorDecl : decl->getMembersOfType<AccessorDecl>())
+ {
+ anyAccessors = true;
+ }
+
+ if(!anyAccessors)
+ {
+ RefPtr<GetterDecl> getterDecl = new GetterDecl();
+ getterDecl->loc = decl->loc;
+
+ getterDecl->ParentDecl = decl;
+ decl->Members.Add(getterDecl);
+ }
+
for(auto mm : decl->Members)
{
checkDecl(mm);
@@ -4662,6 +4688,10 @@ namespace Slang
{
callExpr->type.IsLeftValue = true;
}
+ for(auto refAccessor : subscriptDeclRef.getDecl()->getMembersOfType<RefAccessorDecl>())
+ {
+ callExpr->type.IsLeftValue = true;
+ }
}
// TODO: there may be other cases that confer l-value-ness