From f57a12ea3c983bfc178309c3d8dcfe0bb0d1e9e7 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Fri, 3 Apr 2026 01:06:50 +0200 Subject: [PATCH] fix: correct location for variadicplaceholder nodes Finalize the node after advancing past T_ELLIPSIS so that parser.prev captures the end of '...' rather than the preceding '(' token. Previously start == end and source was empty string. --- src/parser/function.js | 3 ++- test/snapshot/__snapshots__/location.test.js.snap | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/parser/function.js b/src/parser/function.js index 5adebe8ca..51ca34ca6 100644 --- a/src/parser/function.js +++ b/src/parser/function.js @@ -413,8 +413,9 @@ module.exports = { this.token === this.tok.T_ELLIPSIS && this.peek() === ")" ) { - result.push(this.node("variadicplaceholder")()); + const variadicNode = this.node("variadicplaceholder"); this.next(); + result.push(variadicNode()); } else if (this.token !== ")") { result = this.read_non_empty_argument_list(); } diff --git a/test/snapshot/__snapshots__/location.test.js.snap b/test/snapshot/__snapshots__/location.test.js.snap index cdd6fdd3d..49fa5f0cd 100644 --- a/test/snapshot/__snapshots__/location.test.js.snap +++ b/test/snapshot/__snapshots__/location.test.js.snap @@ -4270,11 +4270,11 @@ Program { "kind": "variadicplaceholder", "loc": Location { "end": Position { - "column": 51, + "column": 54, "line": 1, - "offset": 51, + "offset": 54, }, - "source": "", + "source": "...", "start": Position { "column": 51, "line": 1, @@ -11828,11 +11828,11 @@ Program { "kind": "variadicplaceholder", "loc": Location { "end": Position { - "column": 57, + "column": 60, "line": 1, - "offset": 57, + "offset": 60, }, - "source": "", + "source": "...", "start": Position { "column": 57, "line": 1,