Skip to content

token,scanner,parser,checker,cgen: add file_idx to token.Pos#25490

Merged
spytheman merged 8 commits into
vlang:masterfrom
kbkpbot:fix-v-pos-add-file-idx
Oct 12, 2025
Merged

token,scanner,parser,checker,cgen: add file_idx to token.Pos#25490
spytheman merged 8 commits into
vlang:masterfrom
kbkpbot:fix-v-pos-add-file-idx

Conversation

@kbkpbot

@kbkpbot kbkpbot commented Oct 12, 2025

Copy link
Copy Markdown
Contributor

This is a fix for PR #25429
change the file_idx to i16 and col to u16 to keep the same size of token.Pos.
I ran a local v run .github/workflows/compare_pr_to_master.v, and see almost no performance impact.

BTW, integrate the file_idx into token.Pos is help for identify which file this token is come from. In vls, the goto definition function need the filename when it try to jump to the location.

@vlang vlang deleted a comment from huly-for-github Bot Oct 12, 2025
Comment thread vlib/v/scanner/scanner.v
Comment thread vlib/v/scanner/scanner.v
col: s.pos - s.last_nl_pos - 1
line_nr: s.line_nr
pos: s.pos
col: u16(s.pos - s.last_nl_pos - 1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
col: u16(s.pos - s.last_nl_pos - 1)
col: u16_col(s.pos - s.last_nl_pos - 1)

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit 144b57c into vlang:master Oct 12, 2025
83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants