Skip to content

Commit 493c5a9

Browse files
committed
Fix document symbol crash on incomplete functions
1 parent f43cfb5 commit 493c5a9

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- Fixed document symbol crash on incomplete functions
12+
913
## [1.16.1] - 2023-01-30
1014

1115
### Fixed

src/operations/DocumentSymbol.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,19 @@ struct DocumentSymbolsVisitor : public Luau::AstVisitor
9191
bool comma = false;
9292
for (auto* arg : func->args)
9393
{
94-
LUAU_ASSERT(func->argLocation);
95-
createLocalSymbol(arg, func->argLocation.value());
94+
createLocalSymbol(arg, func->argLocation.value_or(func->location));
9695
if (comma)
9796
detail += ", ";
9897
detail += arg->name.value;
9998
comma = true;
10099
}
101100
if (func->vararg)
102101
{
103-
LUAU_ASSERT(func->argLocation);
102+
auto enclosingPosition = func->argLocation.value_or(func->location);
104103
lsp::DocumentSymbol symbol;
105104
symbol.name = "...";
106105
symbol.kind = lsp::SymbolKind::Variable;
107-
symbol.range = {textDocument->convertPosition(func->argLocation->begin), textDocument->convertPosition(func->argLocation->end)};
106+
symbol.range = {textDocument->convertPosition(enclosingPosition.begin), textDocument->convertPosition(enclosingPosition.end)};
108107
symbol.selectionRange = {
109108
textDocument->convertPosition(func->varargLocation.begin), textDocument->convertPosition(func->varargLocation.end)};
110109

0 commit comments

Comments
 (0)