You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using lexer.Tokenize to tokenize input, the IndentLevel for a token is not properly reset when it is supposed to decrease by more than 1 -- the value is only decremented by 1 even if the indent level logically decreases by multiple more.
The indent level for top-level-two-indent-0 should be 0, but it is reported as 3 (because the last indent level for one-indent-4 was 4, and when the scanner processes top-level-two-indent-0, it only decrements the indent level by 1). This mismatch is also propagated down through all child nodes.
Expected behavior
For this specific input, the IndentLevel for top-level-two-indent-0 should be 0.
In general, the scanner's updateIndentLevel function should properly decrement the indent level based on the content/context instead of always just decrementing by 1 (
nmiyake
changed the title
lexer.Tokenize does not properly decrement IndentLevel
scanner.Scanner/lexer.Tokenize does not properly decrement IndentLevel
Feb 24, 2025
Describe the bug
When using
lexer.Tokenize
to tokenize input, theIndentLevel
for a token is not properly reset when it is supposed to decrease by more than 1 -- the value is only decremented by 1 even if the indent level logically decreases by multiple more.As a concrete example, for the input YAML:
The indent level for
top-level-two-indent-0
should be 0, but it is reported as 3 (because the last indent level forone-indent-4
was 4, and when the scanner processestop-level-two-indent-0
, it only decrements the indent level by 1). This mismatch is also propagated down through all child nodes.To Reproduce
Go Playground:
https://go.dev/play/p/QI6toGvzMCE
Self-contained test file:
Expected behavior
For this specific input, the
IndentLevel
fortop-level-two-indent-0
should be 0.In general, the scanner's
updateIndentLevel
function should properly decrement the indent level based on the content/context instead of always just decrementing by 1 (go-yaml/scanner/scanner.go
Lines 150 to 154 in abc7083
Screenshots
If applicable, add screenshots to help explain your problem.
Version Variables
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: