Skip to content

Commit d4d7328

Browse files
committed
Fix NumParam LVar decls in legacy parser
1 parent 29d9c23 commit d4d7328

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

parser/Builder.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ class Builder::Impl {
203203

204204
auto raw_numparam_stack = driver_->numparam_stack.stackCopy();
205205

206+
auto opening_token = raw_numparam_stack.back().opening_token;
207+
206208
// ignore current block scope
207209
raw_numparam_stack.pop_back();
208210

@@ -226,7 +228,11 @@ class Builder::Impl {
226228
}
227229

228230
driver_->lex.declare(name_str);
229-
auto intro = make_unique<LVar>(node->loc, id->name);
231+
232+
// The LVar's location matches the non-zero length NumParams node. See `numparams()` for details.
233+
core::LocOffsets loc = tokLoc(opening_token).copyEndWithZeroLength();
234+
auto intro = make_unique<LVar>(loc, id->name);
235+
230236
auto decls = driver_->alloc.node_list();
231237
decls->emplace_back(toForeign(std::move(intro)));
232238
driver_->numparam_stack.regis(name_str[1] - '0', std::move(decls));

0 commit comments

Comments
 (0)