From ee709cffe520df3cf082dc7923609c42dd14cabc Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 23 Oct 2024 20:45:59 -0700 Subject: [PATCH] Fix language server crash. (#5395) --- source/slang/slang-check-decl.cpp | 7 +++++++ tests/language-server/robustness-8.slang | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 tests/language-server/robustness-8.slang diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index 781a3a237f..8030bcf974 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -7861,6 +7861,13 @@ namespace Slang if (semantics) semantics->ensureDecl(genericTypeConstraintDecl, DeclCheckState::ReadyForReference); auto constraintDeclRef = astBuilder->getDirectDeclRef(genericTypeConstraintDecl); + auto supType = getSup(astBuilder, constraintDeclRef); + if (!supType) + { + args.add(astBuilder->getErrorType()); + shouldCache = false; + continue; + } auto witness = astBuilder->getDeclaredSubtypeWitness( getSub(astBuilder, constraintDeclRef), diff --git a/tests/language-server/robustness-8.slang b/tests/language-server/robustness-8.slang new file mode 100644 index 0000000000..84d6c8945a --- /dev/null +++ b/tests/language-server/robustness-8.slang @@ -0,0 +1,8 @@ +//TEST:LANG_SERVER(filecheck=CHECK): +// +__generic < T : struct> extension T +{ +// CHECK: null +//HOVER:7,32 + __init(StructuredBuffer) {} +} \ No newline at end of file