diff options
| author | ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> | 2025-05-30 14:54:31 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-30 21:54:31 +0000 |
| commit | 3ca27faa23a92124f26875a6f00bcfc3a1c6431e (patch) | |
| tree | a2fad6f0e0bbf99a574a5a6d0348970dcd16ddf2 /source | |
| parent | b16eb592cc31b7cc9ba3d2f9525486c282996a9e (diff) | |
Ensure we do not have an `initExpr` on a `VarDecl` inside an `InterfaceDecl` (#7283)
* Ensure we do not have an initExpr on a var inside an InterfaceDecl
Ensure we do not have an initExpr on a var inside an InterfaceDecl. If we do, send an error.
Ensure the language server does not segfault with this error as per the issue.
* format code
* split tests
---------
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-check-decl.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 71aa71e69..cc65edd2f 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -2464,6 +2464,17 @@ bool DiagnoseIsAllowedInitExpr(VarDeclBase* varDecl, DiagnosticSink* sink) return false; } + if (as<InterfaceDecl>(varDecl->parentDecl)) + { + if (sink && varDecl->initExpr) + sink->diagnose( + varDecl, + Diagnostics::cannotHaveInitializer, + varDecl, + "an interface requirement"); + return false; + } + return true; } |
