Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract type coercion missing for function arguments #5523

Open
jimblandy opened this issue Apr 11, 2024 · 1 comment · May be fixed by #6577
Open

Abstract type coercion missing for function arguments #5523

jimblandy opened this issue Apr 11, 2024 · 1 comment · May be fixed by #6577
Assignees
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator type: bug Something isn't working

Comments

@jimblandy
Copy link
Member

From conversation in #5515:

I think this works per the spec - the type of a literal is AbstractInt which should be coerced into whatever makes the most sense in context. I'm not sure how thorough our implementation is in 0.19 or trunk.

It works in a few spots (simple integer expressions, for example) but call a function that takes a u32 and pass a 0 and you get this beauty:

Shader validation error:
┌─ surface.wgsl:367:12

367 │ return with_cond(vertex_ix, 0);
│ ^^^^^^^^^^^^^^^^^^^^^^^
│ │ │
│ │ naga::Expression [2]
│ invalid function call

Entry point vs_main_cond at Vertex is invalid
Call to [11] is invalid
Argument 1 value [2] doesn't match the type [1]

It wants a 0u. Don't get me started on that error message... my goodness.

@sagudev
Copy link
Contributor

sagudev commented Nov 18, 2024

today I noticed similar problem:

fn f() {
    let n = vec3f(1,0,1);
    let l = vec3f(1,1,0);
    let lambert = max(dot(n, l), 0);// needs 0. to work
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator type: bug Something isn't working
Projects
Status: No status
3 participants