cts icon indicating copy to clipboard operation
cts copied to clipboard

wgsl: validate scoping rules

Open dj2 opened this issue 3 years ago • 1 comments

  • [ ] Access variable not in-scope is invalid
  • [ ] Shadow a module scoped variable
    • [x] Module-scoped variable declared before function
    • [ ] Module-scoped variable declared after function
  • [x] Shadow a function name inside the function allowed
  • [x] Shadow a function name as a parameter name is allowed
  • [x] Shadow variable in inner scope allowed
  • [ ] Shadow variable in same scope denied.
  • [x] Shadow of builtin function
    • [x] #3705
    • [x] Inside a function is allowed
  • [x] Shadow a parameter name inside a block
  • [x] Shadow of a for scoped variable
  • [ ] Shadow of a type alias name
  • [ ] Shadow of a struct name
  • [ ] Use before definition
    • [ ] type alias
    • [ ] module scoped variable
    • [ ] struct
    • [x] call a function
  • [ ] Validate that the following are rejected when a shadow is in scope
    • [ ] a function name, and then trying to call the function
    • [ ] a type alias, and then trying to use as a type
    • [ ] a struct name, and then trying to use the struct
    • [ ] a built-in function name, and then trying to call the function
  • [ ] Validate that a non-module scoped identifier can only be used after declaration

See example in https://www.w3.org/TR/WGSL/#declaration-and-scope for possible others.

dj2 avatar May 24 '22 20:05 dj2

  • Builtin shadowing tests: https://github.com/gpuweb/cts/blob/main/src/webgpu/shader/validation/parse/shadow_builtins.spec.ts
  • Other shadowing tests: https://github.com/gpuweb/cts/blob/main/src/webgpu/shader/execution/shadow.spec.ts

dj2 avatar Apr 23 '24 20:04 dj2