software-mansion / software-mansion/TypeGPU

bug: Unary `-` is not supported for `u32` values

Open
#2,846 3 comments 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

Evidence:

Image
const incrementPipeline = root.createGuardedComputePipeline(() => {
  'use gpu';
  let value = -d.u32(7.5);
  counter.$ = value;
});

Causes:

Image

Possible fixes

  1. We can automatically wrap u32 values with i32(...) before applying the unary negation operator.
  2. We can enforce that operands of the unary - cannot be of type u32

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 createGuardedComputePipeline example and trace d.u32(7.5) through handling of the unary - operator. Determine the intended behavior for u32 operands from the two proposed fixes, then verify that the example no longer produces the reported error and that the chosen behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers, computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.