schell / schell/wgsl-rs

Shadowing function arguments compiled sucessfully but generates invalid wgsl

Closed
#163 0 comments 0 reactions 0 assignees View on GitHub
bug P1
Dominant language
Rust
Stars
62
Forks
5
Avg merge
1d 5h
Merged PRs (30d)
14

Description

```rust
#[wgsl]
pub mod my_shader {
pub fn my_func(x: f32) {
let x = 0.0;
}
}
```

compiles successfully, but when you try and run the wgsl:

```
Caused by:
In Device::create_shader_module, label = 'compute'

Shader 'compute' parsing error: redefinition of `x`
┌─ wgsl:68:12

68 │ fn my_func(x: f32) {
│ ^ previous definition of `x`
69 │ let x = 0.0;
│ ^ redefinition of `x`
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided Rust reproduction using the #[wgsl] entry point and my_func, then inspect the generated WGSL and reproduce the error when creating the shader module. Trace how function arguments and local bindings are emitted; done means the example no longer produces invalid WGSL and the generated shader is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.