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

[wgsl-in] Immutable array cannot be accessed with mutable index #4920

Closed
HactarCE opened this issue Dec 22, 2023 · 1 comment
Closed

[wgsl-in] Immutable array cannot be accessed with mutable index #4920

HactarCE opened this issue Dec 22, 2023 · 1 comment
Labels
area: naga front-end lang: WGSL WebGPU Shading Language naga Shader Translator type: bug Something isn't working

Comments

@HactarCE
Copy link
Contributor

Description
An array assigned to an immutable variable cannot be accessed using an index from a mutable binding.

Repro steps
Compile this code in a WGSL shader:

fn f() {
    let a = array<f32, 10>();

    let i = 0;
    let x = a[i]; // compiles fine

    var j = 0;
    let y = a[j]; // error: The expression may only be indexed by a constant
}

Expected vs observed behavior
I expect f to compile with no issue, but instead I get an error when attempting to access a[j].

Platform

  • OS: macOS Sonoma 14.2
  • wgpu: latest from trunk
@jimblandy jimblandy added type: bug Something isn't working naga Shader Translator area: naga front-end lang: WGSL WebGPU Shading Language labels Dec 27, 2023
@nical
Copy link
Contributor

nical commented Jan 3, 2024

Duplicate of #4337

@nical nical marked this as a duplicate of #4337 Jan 3, 2024
@cwfitzgerald cwfitzgerald closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2024
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
None yet
Development

No branches or pull requests

4 participants