Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

[wgsl-in] Turn Error::Other into Error::Internal, to help devs. #2574

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/front/wgsl/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub enum Error<'a> {
},
FunctionReturnsVoid(Span),
InvalidWorkGroupUniformLoad(Span),
Other,
Internal(&'static str),
ExpectedConstExprConcreteIntegerScalar(Span),
ExpectedNonNegative(Span),
ExpectedPositiveArrayLength(Span),
Expand Down Expand Up @@ -667,10 +667,10 @@ impl<'a> Error<'a> {
labels: vec![(span, "".into())],
notes: vec!["passed type must be a workgroup pointer".into()],
},
Error::Other => ParseError {
message: "other error".to_string(),
Error::Internal(message) => ParseError {
message: "internal WGSL front end error".to_string(),
labels: vec![],
notes: vec![],
notes: vec![message.into()],
},
Error::ExpectedConstExprConcreteIntegerScalar(span) => ParseError {
message: "must be a const-expression that resolves to a concrete integer scalar (u32 or i32)".to_string(),
Expand Down
5 changes: 2 additions & 3 deletions src/front/wgsl/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2305,13 +2305,12 @@ impl Parser {
if !self.rules.is_empty() {
log::error!("Reached the end of global decl, but rule stack is not empty");
log::error!("Rules: {:?}", self.rules);
return Err(Error::Other);
return Err(Error::Internal("rule stack is not empty"));
};

match binding {
None => Ok(()),
// we had the attribute but no var?
Some(_) => Err(Error::Other),
Some(_) => Err(Error::Internal("we had the attribute but no var?")),
}
}

Expand Down