Skip to content

Commit 10c458c

Browse files
committed
Fix function parameters autocomplete in calls for new solver
In new solver, the parameters are typed as 'unknown' if they don't have an explicit type annotation. getParameterExtents treats 'unknown' as an optional type. But note that the new solver would still emit a type error due to mismatching arg counts (see LuauArityMismatchOnUndersaturatedUnknownArguments flag). Let's manually increment the minimum parameter count when we encounter 'unknown' and treat it as a required type, similar to what this flag does.
1 parent 5b613f9 commit 10c458c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2222
- Autocomplete now properly respects Luau's ParenthesesRecommendation and puts the cursor inside of the parentheses when
2323
autocompleting a function call where the arguments are all optional / any (e.g., `require()` or
2424
`wait()`) ([#317](https://github.com/JohnnyMorganz/luau-lsp/issues/317))
25+
- Fixed autocomplete of function calls in new solver not inserting parameter names if the parameters do not have a type
26+
annotation
2527

2628
## [1.52.1] - 2025-07-12
2729

src/operations/Completion.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ static std::pair<std::string, std::string> computeLabelDetailsForFunction(const
357357

358358
auto [minCount, _] = Luau::getParameterExtents(Luau::TxnLog::empty(), ftv->argTypes, true);
359359

360+
// Include 'unknown' arguments as required types
361+
for (auto arg : ftv->argTypes)
362+
if (Luau::get<Luau::UnknownType>(follow(arg)))
363+
minCount += 1;
364+
360365
auto it = Luau::begin(ftv->argTypes);
361366
for (; it != Luau::end(ftv->argTypes); ++it, ++argIndex)
362367
{

0 commit comments

Comments
 (0)