Skip to content

Commit

Permalink
fix(wgsl-in): print debug repr. of unexpected tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Jan 13, 2025
1 parent 2088645 commit 237a94a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion naga/src/front/wgsl/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ impl<'a> Error<'a> {
};
ParseError {
message: format!(
"expected {}, found '{}'",
"expected {}, found {:?}",
expected_str, &source[unexpected_span],
),
labels: vec![(unexpected_span, format!("expected {expected_str}").into())],
Expand Down
14 changes: 14 additions & 0 deletions naga/tests/wgsl_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2432,3 +2432,17 @@ fn const_assert_failed() {
"###,
);
}

#[test]
fn reject_utf8_bom() {
check(
"\u{FEFF}fn main() {}",
r#"error: expected global item ('struct', 'const', 'var', 'alias', 'fn', 'diagnostic', 'enable', 'requires', ';') or the end of the file, found "\u{feff}"
┌─ wgsl:1:1
1 │ fn main() {}
│ expected global item ('struct', 'const', 'var', 'alias', 'fn', 'diagnostic', 'enable', 'requires', ';') or the end of the file
"#,
);
}

0 comments on commit 237a94a

Please sign in to comment.