Closed
Description
This sort of construct causes a syntax error:
fn foo() -> u32 {
if true { 3i32 } else { 4i32 } as u32
}
error: expected expression, found keyword `as`
The same syntax works fine in an assignment form:
let foo = if true { 3i32 } else { 4i32 } as u32;
And so it is surprising that it doesn't work in a function context.
When parentheses are added, it parses in the function context too:
fn foo() -> u32 {
(if true { 3i32 } else { 4i32 }) as u32
}
The same applies to using match
and presumably possibly other expressions as well.
Seems like a bug?