When an identifier is used, it must be in scope for some declaration, or as part of a directive. When an identifier is used in scope of one or more declarations for that name, the identifier will denote the object of the non-module-scope declaration appearing closest to that use, or the module-scope declaration if no other declaration is in scope. We say the identifier use resolves to that declaration.
This is not quite right, unfortunately.
Example 1:
let rgba8unorm: i32 = 12;
[[group(0),binding(0)]] var texture_storage_2d<rgba8unorm,write>;
// this use of rgba8unorm does not denote the value 12.
Example 2:
let binding: i32 = 1;
[[group(0),binding(0)]] var texture_storage_2d<rgba8unorm,write>;
// this use of binding does not denote the value 1
Example 3:
enable foobar; // this use of foobar does not denote the value 1
let foobar: i32 = 1;
In each case the scope of the declaration includes the uses of the identifier, but the identifier does not denote the declared object.
Basically, we need to describe spots in the source text where the normal identifier resolution rules are not active. These would be:
- in the text of a directive
- attribute names
- parameters to certain attributes: interpolate, stage, builtin
- texel format part of a storage texture type
This is not quite right, unfortunately.
Example 1:
Example 2:
Example 3:
In each case the scope of the declaration includes the uses of the identifier, but the identifier does not denote the declared object.
Basically, we need to describe spots in the source text where the normal identifier resolution rules are not active. These would be: