Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

fix: Const conversions

Aperta
#3,050 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
compilers

Direzione di ricerca

The issue involves constant propagation and type conversions in the TypeGPU compiler. Look at the code handling implicit/explicit conversions (like d.i32()) and how they affect the 'origin' (compile-time vs runtime). The failing tests are in the test suite; start by running them to see the error. Investigate the resolution logic for switch statements and constant folding to ensure conversions preserve compile-time constness.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Implicit and explicit conversions currently change the origin to runtime.
This breaks the following switch expressions:

  it('...', () => {
    const one = tgpu.const(d.u32, 1);
    const fn = () => {
      'use gpu';
      switch (d.i32(1)) {
        case one.$:
      }
    };

    expect(() => tgpu.resolve([fn])).toThrowErrorMatchingInlineSnapshot(`
      [Error: Resolution of the following tree failed:
      - <root>
      - fn*:fn
      - fn*:fn(): All of switch tests must be constant.
      Test 'one.$' is not known at comptime, making the following switch statement invalid. 
      This error may be caused by an implicit conversion.
      switch (d.i32(1)) {
        case one.$:
      }]
    `);
  });

  it('...', () => {
    const one = tgpu.const(d.i32, 1);
    const fn = () => {
      'use gpu';
      switch (d.i32(1)) {
        case d.i32(one.$):
      }
    };

    expect(() => tgpu.resolve([fn])).toThrowErrorMatchingInlineSnapshot(`
      [Error: Resolution of the following tree failed:
      - <root>
      - fn*:fn
      - fn*:fn(): All of switch tests must be constant.
      Test 'd.i32(one.$)' is not known at comptime, making the following switch statement invalid. 
      This error may be caused by an implicit conversion.
      switch (d.i32(1)) {
        case d.i32(one.$):
      }]
    `);
  });
Lingua principale
TypeScript
Stelle
3.3k
Fork
135
Merge medio
4g 1h
PR unite (30g)
65

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di software-mansion/TypeGPU

Tutte le issue di software-mansion/TypeGPU

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.