software-mansion / software-mansion/TypeGPU
fix: Simultaneous implicit casts and derefs
Open
Nobody has claimed this yet.
bug
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 122
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 34
Description
This code silently produces invalid WGSL.
it('disallows implicit casts in d.ref', () => {
const modify = tgpu.fn([d.ptrFn(d.u32)])((numRef) => {
'use gpu';
numRef.$ += 1;
});
const main = tgpu.fn([])(() => {
'use gpu';
const num = d.f32();
modify(d.ref(num));
});
expect(tgpu.resolve([main])).toMatchInlineSnapshot(`
"fn modify(numRef: ptr<function, u32>) {
(*numRef) += 1u;
}
fn main() {
const num = 0f;
modify((&num));
}"
`);
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the shown TypeScript test with d.ptrFn, d.ref, and tgpu.resolve as the entry point, and trace how the simultaneous implicit cast and dereference are emitted. Verify the focused test no longer produces invalid WGSL and that implicit casts in d.ref are disallowed as intended.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100