Skip to content

[wgsl] Intra-scope shadowing? #1473

@kdashg

Description

@kdashg

#1472 might add the super-common inter-scope shadowing case.

Most languages don't support intra-scope shadowing, but there are times when it can be useful to effectively change the type (or modifiers) of an identifier.

  var sum = 0;
  for (var i = 0; i < N; i+=1) {
    sum += data[i];
  }
  const sum = sum;

This seems fairly straight-forward to support, though I expect some will feel that "we shouldn't support something no one should ever do", for some personal conviction of "should".

I desire this in other programming languages, and I would be happy if it were possible (and obviously not mandatory) in WGSL.
I don't think this is important, but some people feel this would be nice to have.

Metadata

Metadata

Assignees

No one assigned

    Labels

    wgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions