Give template segments the location of their text
Why
A template segment's location started at the delimiter before it (a backquote or }) and ended before the one after it (${ or a backquote), so it was neither the text nor the text with its delimiters. The old shape is what made the v0 bridge lose a character of a template's location (#9164). Segments now cover their text only.
modifiedAST template segment locations
let y = `a${b}c`text
Before
After
expression 8..16 segments "a" 8..10, "c" 13..15covering `a${b}c` `a }cexpression 8..16 segments "a" 9..10, "c" 14..15covering `a${b}c` a c
modifiedDiagnostic invalid escape in a template
let invalid = `\unicode`diagnostic
Before
After
Syntax error!Syntax error!A.res:1:15-23A.res:1:16-23
Review
- What else reads segment locations? Invalid escape errors, now pointing at the text;
Ast_raw.payload_loc, which now widens a %raw template by one character on each side; and the v0 bridge, which keeps each segment's location as it is.