From 43dffcde78227113a0e62b02857eaf4ed6ea6e7e Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 9 Sep 2025 22:14:05 -0700 Subject: Fix language server auto-complete regression in debug build. (#8416) Fixes this regression: ```slang struct MyType { // Regression Condition 1: there must be more than one member in the lookup scope. float v; int getSum() { return 0; } } void m(MyType t) { // Regression condition 2: the completion must be in an init expression. // Regression condition 3: none of the candidate members can coerce to the expected type. // Regression behavior: no completion candidates are shown, because // SemanticsVisitor::resolveOverloadedLookup throws an error when there are 0 applicable candidates // after type coercion filtering. Texture2D x = t.; // completion request after . here } ``` The root cause is that we shouldn't be applying candidate filtering on the candidate list when in completion checking mode. Closes #8417. --- tests/language-server/completion-in-initexpr.slang | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/language-server/completion-in-initexpr.slang (limited to 'tests') diff --git a/tests/language-server/completion-in-initexpr.slang b/tests/language-server/completion-in-initexpr.slang new file mode 100644 index 000000000..8eec82991 --- /dev/null +++ b/tests/language-server/completion-in-initexpr.slang @@ -0,0 +1,20 @@ +//TEST:LANG_SERVER(filecheck=CHECK): +//COMPLETE:17,21 +struct MyType +{ + // Regression Condition 1: there must be more than one member in the lookup scope. + float v; + int getSum() { return 0; } +} + +void m(MyType t) +{ + // Regression condition 2: the completion must be in an init expression. + // Regression condition 3: none of the candidate members can coerce to the expected type. + // Regression behavior: no completion candidates are shown, because + // SemanticsVisitor::resolveOverloadedLookup throws an error when there are 0 applicable candidates + // after type coercion filtering. + Texture2D x = t.; +} + +// CHECK: getSum -- cgit v1.2.3