Skip to content

fix: Array casts #2521

@aleksanderkatan

Description

@aleksanderkatan

Problem analogous to #2450.
For example, here we generate invalid wgsl:

  it('...', () => {
    const A = d.arrayOf(d.struct({ p: d.u32 }), 4);
    const B = d.arrayOf(d.struct({ p: d.f32 }), 4);

    const helper = tgpu.fn([B])((b) => {
      'use gpu';
    });

    const main = tgpu.fn([])(() => {
      'use gpu';
      const a = A();
      helper(a);
    });

    expect(tgpu.resolve([main])).toMatchInlineSnapshot(`
      "struct item {
        p: u32,
      }

      struct item_1 {
        p: f32,
      }

      fn helper(b: array<item_1, 4>) {

      }

      fn main() {
        let a = array<item, 4>();
        helper(a);
      }"
    `);
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions