diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/check.cpp | 22 | ||||
| -rw-r--r-- | source/slang/diagnostic-defs.h | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp index ed2ed4a1b..6bb7c232f 100644 --- a/source/slang/check.cpp +++ b/source/slang/check.cpp @@ -3471,11 +3471,33 @@ namespace Slang decl->SetCheckState(DeclCheckState::CheckedHeader); + for(auto mm : decl->Members) + { + checkDecl(mm); + } + decl->SetCheckState(DeclCheckState::Checked); } void visitAccessorDecl(AccessorDecl* decl) { + // An acessor must appear nested inside a subscript declaration (today), + // or a property declaration (when we add them). It will derive + // its return type from the outer declaration, so we handle both + // of these checks at the same place. + auto parent = decl->ParentDecl; + if(auto parentSubscript = dynamic_cast<SubscriptDecl*>(parent)) + { + decl->ReturnType = parentSubscript->ReturnType; + } + // TODO: when we add "property" declarations, check for them here + else + { + getSink()->diagnose(decl, Diagnostics::accessorMustBeInsideSubscriptOrProperty); + } + + decl->SetCheckState(DeclCheckState::CheckedHeader); + // TODO: check the body! decl->SetCheckState(DeclCheckState::Checked); diff --git a/source/slang/diagnostic-defs.h b/source/slang/diagnostic-defs.h index 52f5d48a0..10b2dbd1e 100644 --- a/source/slang/diagnostic-defs.h +++ b/source/slang/diagnostic-defs.h @@ -246,6 +246,7 @@ DIAGNOSTIC(38003, Error, entryPointSymbolNotAFunction, "entry point '$0' must be DIAGNOSTIC(38100, Error, typeDoesntImplementInterfaceRequirement, "type '$0' does not provide required interface member '$1'") DIAGNOSTIC(38101, Error, thisExpressionOutsideOfTypeDecl, "'this' expression can only be used in members of an aggregate type") DIAGNOSTIC(38102, Error, initializerNotInsideType, "an 'init' declaration is only allowed inside a type or 'extension' declaration") +DIAGNOSTIC(38102, Error, accessorMustBeInsideSubscriptOrProperty, "an accessor declaration is only allowed inside a subscript or property declaration") // // 4xxxx - IL code generation. |
