BlockComment from position is incorrect #52

Closed
opened 2026-01-25 05:21:08 +01:00 by BlueGreenMagick · 2 comments
BlueGreenMagick commented 2026-01-25 05:21:08 +01:00 (Migrated from github.com)

BlockComment from position is incorrect when there are other skipped tokens beforehand.

For example, below is an example code and the tree it is parsed into.
You can see that the BlockComment block's from position is all set to 10 when it should instead be21 and 36 respectively.

let x = 1; // abcde 
/* abc *///xxx
/*abc */ 
{
  "type": "Script",
  "from": 0,
  "to": 47,
  "children": [
    {
      "type": "VariableDeclaration",
      "from": 0,
      "to": 10,
      "children": [
        { "type": "let", "from": 0, "to": 3 },
        { "type": "VariableDefinition", "from": 4, "to": 5 },
        { "type": "Equals", "from": 6, "to": 7 },
        { "type": "Number", "from": 8, "to": 9 },
        { "type": ";", "from": 9, "to": 10 }
      ]
    },
    { "type": "LineComment", "from": 11, "to": 20 },
    { "type": "BlockComment", "from": 10, "to": 30 },
    { "type": "LineComment", "from": 30, "to": 35 },
    { "type": "BlockComment", "from": 10, "to": 44 }
  ]
}

Version information

@lezer/javascript: 1.5.4
@lezer/common: 1.5.0
@lezer/lr@1.4.7
BlockComment `from` position is incorrect when there are other skipped tokens beforehand. For example, below is an example code and the tree it is parsed into. You can see that the `BlockComment` block's `from` position is all set to `10` when it should instead be`21` and `36` respectively. ```ts let x = 1; // abcde /* abc *///xxx /*abc */ ``` ```json { "type": "Script", "from": 0, "to": 47, "children": [ { "type": "VariableDeclaration", "from": 0, "to": 10, "children": [ { "type": "let", "from": 0, "to": 3 }, { "type": "VariableDefinition", "from": 4, "to": 5 }, { "type": "Equals", "from": 6, "to": 7 }, { "type": "Number", "from": 8, "to": 9 }, { "type": ";", "from": 9, "to": 10 } ] }, { "type": "LineComment", "from": 11, "to": 20 }, { "type": "BlockComment", "from": 10, "to": 30 }, { "type": "LineComment", "from": 30, "to": 35 }, { "type": "BlockComment", "from": 10, "to": 44 } ] } ``` ### Version information ``` @lezer/javascript: 1.5.4 @lezer/common: 1.5.0 @lezer/lr@1.4.7 ```
marijnh commented 2026-01-25 13:38:12 +01:00 (Migrated from github.com)

This was a regression in @lezer/lr 1.4.6. Version 1.4.8 should fix it.

This was a regression in @lezer/lr 1.4.6. Version 1.4.8 should fix it.
BlueGreenMagick commented 2026-01-25 13:56:14 +01:00 (Migrated from github.com)

Thanks for such a quick fix! 1.4.8 fixed the issue 😃

Thanks for such a quick fix! 1.4.8 fixed the issue 😃
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lezer/javascript#52
No description provided.