Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SourceLocation line_position is undocumented #5385

Closed
stefnotch opened this issue Mar 13, 2024 · 1 comment · Fixed by #5386
Closed

SourceLocation line_position is undocumented #5385

stefnotch opened this issue Mar 13, 2024 · 1 comment · Fixed by #5386

Comments

@stefnotch
Copy link
Contributor

stefnotch commented Mar 13, 2024

Description
The source location line_position does not indicate whether it is in UTF-8 code units, or if it counts code points (~characters)

wgpu/naga/src/span.rs

Lines 116 to 117 in 6040820

/// 1-based column of the start of this span
pub line_position: u32,

Observed behavior
The actual computation counts characters

let line_position = source[line_start..self.start as usize].chars().count() as u32 + 1;

@stefnotch stefnotch changed the title SourceLocation line_position is wrong SourceLocation line_position is undocumented Mar 13, 2024
@stefnotch
Copy link
Contributor Author

Documenting this should be valuable, since Firefox is a famous user of wgpu and even they messed it up https://bugzilla.mozilla.org/show_bug.cgi?id=1885238

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 a pull request may close this issue.

1 participant