Skip to content

Commit 269a2b9

Browse files
antonsyndclaude
andcommitted
fix(parser): fix ColumnEnd for string and f-string literals
StringLiteral used Previous.Value.Length for ColumnEnd, but Value excludes quotes. Use Previous.Length (which returns SourceLength when available) to include the full source extent with quotes. FStringLiteral set ColumnEnd to the FStringEnd token's column without accounting for the token's length. Add endToken.Length so ColumnEnd is one past the closing quote, consistent with other node types. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 7ee6f40 commit 269a2b9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Sharpy.Compiler/Parser/Parser.Primaries.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private Expression ParsePrimary()
101101
LineStart = startLine,
102102
ColumnStart = startColumn,
103103
LineEnd = Previous.Line,
104-
ColumnEnd = Previous.Column + Previous.Value.Length,
104+
ColumnEnd = Previous.Column + Previous.Length,
105105
Span = GetSpanFromToken(token)
106106
};
107107
}
@@ -118,7 +118,7 @@ private Expression ParsePrimary()
118118
LineStart = startLine,
119119
ColumnStart = startColumn,
120120
LineEnd = Previous.Line,
121-
ColumnEnd = Previous.Column + Previous.Value.Length,
121+
ColumnEnd = Previous.Column + Previous.Length,
122122
Span = GetSpanFromToken(token)
123123
};
124124
}

src/Sharpy.Compiler/Parser/Parser.Types.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ private FStringLiteral ParseSegmentedFString(int startLine, int startColumn, Tok
660660
LineStart = startLine,
661661
ColumnStart = startColumn,
662662
LineEnd = endLine,
663-
ColumnEnd = endColumn,
663+
ColumnEnd = endColumn + endToken.Length,
664664
Span = GetSpanFromTokens(startToken, endToken)
665665
};
666666
}

0 commit comments

Comments
 (0)