Skip to content

bug: Runtime ternaries should require non-alias arguments #2752

Description

@iwoplaza

Insane test case:

function main() {
  'use gpu';
  const boid = Boid();

  const runtimeBool = false;
  const x = runtimeBool ? boid.pos : boid.vel;
  // should have to require: const x = runtimeBool ? d.vec3f(boid.pos) : d.vec3f(boid.vel);
  const y = boid.pos;

  return x;
}

expect(tgpu.resolve([main])).toMatchInlineSnapshot(`
  "struct Boid {
    pos: vec3f,
    vel: vec3f,
  }

  fn main() -> vec3f {
    var boid = Boid();
    const runtimeBool = false;
    let x = select(boid.vel, boid.pos, runtimeBool);
    let y = (&boid.pos);
    return x;
  }"
`);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions