diff options
| author | Darren Wihandi <65404740+fairywreath@users.noreply.github.com> | 2025-01-24 16:12:38 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-24 13:12:38 -0800 |
| commit | 92c9fffb95c92b0bc07eb1c656375928b5cd5c33 (patch) | |
| tree | 7faf537e1d56a22cd8e16133867da745b32b2aef /source/slang/slang-syntax.cpp | |
| parent | ac174d260d90b66ebbc8264001a75b9527611cbc (diff) | |
improve error message on generic value decls (#6169)
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-syntax.cpp')
| -rw-r--r-- | source/slang/slang-syntax.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/slang/slang-syntax.cpp b/source/slang/slang-syntax.cpp index 6fdd5088a..e479f1b9d 100644 --- a/source/slang/slang-syntax.cpp +++ b/source/slang/slang-syntax.cpp @@ -284,7 +284,18 @@ SourceLoc getDiagnosticPos(DeclRefBase* declRef) { if (!declRef) return SourceLoc(); - return declRef->getDecl()->loc; + return getDiagnosticPos(declRef->getDecl()); +} + +SourceLoc getDiagnosticPos(Decl* decl) +{ + if (!decl) + return SourceLoc(); + if (decl->getNameLoc().isValid()) + { + return decl->getNameLoc(); + } + return decl->loc; } // !!!!!!!!!!!!!!!!!!!!!!!!!!!!! Free functions !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
