software-mansion / software-mansion/TypeGPU

[RFC] fix: disallow calls on LHS of assignments

Open
#2,488 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
3.2k
Forks
122
Avg merge
3d 5h
Merged PRs (30d)
34

Description

it('disallows calls on lhs', () => {
  const getVec = () => {
    'use gpu';
    return d.vec2u(1, 2);
  };

  const fn = () => {
    'use gpu';
    getVec().x = 1;
  };

  expect(tgpu.resolve([fn])).toMatchInlineSnapshot(`
    "fn getVec() -> vec2u {
      return vec2u(1, 2);
    }

    fn fn_1() {
      getVec().x = 1u;
    }"
  `);
});

This is an invalid WGSL. However, I see no way on how this could potentially be useful, so is there really a need handle this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the inline test using tgpu.resolve and inspect how the shown TypeScript assignment is converted into WGSL. Determine the intended handling for calls on the left-hand side, then update the regression coverage so the generated result no longer permits invalid WGSL.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
computer-graphics
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.