Skip to content

fix(positions): remaining column inconsistencies after #797 #830

Closed

Description

@ajitpratap0

Follow-up items from the Opus review of PR #826 (refs #797).

1. Quoted identifier newline error uses rune-based column instead of byte column

pkg/sql/tokenizer/tokenizer.go, readQuotedIdentifierSlow (~line 1318): the newline-terminated quoted identifier error builds its models.Location from the rune-based internal Position.Column instead of t.toSQLPosition(startPos) (byte-based). This contradicts the models.Location doc, which specifies byte columns.

The EOF branch already uses t.toSQLPosition(startPos).

Repro: x\t/* c */ é\t"ab\nc" reports column 13, but the opening quote is at byte column 14.

The same pattern exists in the unused StringLiteralReader (string_literal.go).

Fix:

  • Use t.toSQLPosition(startPos) in the newline branch, matching the EOF branch.
  • Apply the same fix in string_literal.go.
  • Add a multi-byte regression test that asserts the byte column.

2. L006 column alignment reports the wrong column

pkg/linter/rules/style/column_alignment.go: getIndentSize counts a tab as 4 columns and the rule reports Location.Column = indent+1. The reported column should be a byte offset.

Fix:

  • Keep tab = 4 when comparing indentation widths.
  • Report the byte offset of the first non-whitespace character, plus 1, as Location.Column.

3. Tighten TestTokenPositions_CommentsKeepOwnPositions

Strengthen the test to assert tokens[2].Start >= Comments[0].End, so it checks that tokens after a comment do not overlap the comment's span.


🤖 Generated with Claude Code

https://claude.ai/code/session_01RkzVu3JY9Y6BRWfjesWts9

Activity

  1. ajitpratap0 commented on Oct 21, 2026

    @ajitpratap0
    OwnerAuthor

    Cross-reference: #827 (fix(tokenizer): point unterminated-literal errors at the opener...) already implements item 1 here. Its diff switches the readQuotedIdentifierSlow newline branch to t.toSQLPosition(startPos), moves string_literal.go onto the same byte-column rule, and adds multibyte/tab regression cases. It is currently conflicting with main and needs a rebase.

    Not covered by #827: item 2 (L006 getIndentSize / reported column in pkg/linter/rules/style/column_alignment.go) and item 3 (the TestTokenPositions_CommentsKeepOwnPositions assertion). Item 3 is a small tokenizer-test change that #827 could absorb; item 2 can stay here. Suggest keeping this issue open for 2 (and 3 if #827 does not take it) once #827 merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions