mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[wgsl] Make colon in case optional (#1801)
This commit is contained in:
@@ -3722,7 +3722,7 @@ impl Parser {
|
||||
break value;
|
||||
}
|
||||
} else {
|
||||
lexer.expect(Token::Separator(':'))?;
|
||||
lexer.skip(Token::Separator(':'));
|
||||
break value;
|
||||
}
|
||||
cases.push(crate::SwitchCase {
|
||||
@@ -3742,7 +3742,7 @@ impl Parser {
|
||||
});
|
||||
}
|
||||
(Token::Word("default"), _) => {
|
||||
lexer.expect(Token::Separator(':'))?;
|
||||
lexer.skip(Token::Separator(':'));
|
||||
let (fall_through, body) =
|
||||
self.parse_switch_case_body(lexer, context.reborrow())?;
|
||||
cases.push(crate::SwitchCase {
|
||||
|
||||
@@ -329,6 +329,24 @@ fn parse_switch() {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_switch_optional_colon_in_case() {
|
||||
parse_str(
|
||||
"
|
||||
fn main() {
|
||||
var pos: f32;
|
||||
switch (3) {
|
||||
case 0, 1 { pos = 0.0; }
|
||||
case 2 { pos = 1.0; fallthrough; }
|
||||
case 3 {}
|
||||
default { pos = 3.0; }
|
||||
}
|
||||
}
|
||||
",
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_parentheses_switch() {
|
||||
parse_str(
|
||||
|
||||
Reference in New Issue
Block a user