You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
on 24.0.0 naga does not seem to support automatic type conversion in return statements. Is it a bug?
this fails validation
fnfoo(x:u32) -> u32{return0;// this is ERR, but return 0u; is OK}
error: Function [0] 'foo' is invalid
┌─ wgsl:1:1
│
1 │ ╭ fn foo(x: u32) -> u32 {
2 │ │ return 0;
│ │ ^ naga::Expression [1]
│ ╰─────────────^ naga::Function [0]
│
= The `return` value Some([1]) does not match the function return value
The WGSL spec is not completely clear about when automatic conversion is allowed to happen (it is clarified on a case-by-case basis, e.g. for call statements in the overload resolution section, but the return statement spec just says The type of the return value must match the return type of the function.)
I suspect that the spec intent for return expressions is the same as for declarations with an abstract initializer and explicit type, i.e. the expression is automatically converted to the return type if a conversion exists. this is also what tint/dawn does.
The text was updated successfully, but these errors were encountered:
related #4400
Description
on 24.0.0 naga does not seem to support automatic type conversion in return statements. Is it a bug?
this fails validation
Repro steps
link to WESL playground. hit compile.
Expected vs observed behavior
The WGSL spec is not completely clear about when automatic conversion is allowed to happen (it is clarified on a case-by-case basis, e.g. for call statements in the overload resolution section, but the return statement spec just says
The type of the return value must match the return type of the function.
)I suspect that the spec intent for return expressions is the same as for declarations with an abstract initializer and explicit type, i.e. the expression is automatically converted to the return type if a conversion exists. this is also what tint/dawn does.
The text was updated successfully, but these errors were encountered: