Comments (2)
The docs do say "Variables declared in init-expression or condition-expression are only in scope until the end of the sub-statement of the for loop." but don't indicate that the for-statement itself actually introduces a new scope, only that the sub-statement does not introduce one.
Interestingly, the grammar includes statement_no_new_scope
to cover this case, but doesn't clearly indicate where scopes are introduced.
from glsl.
I also discovered Section 4.2 states: "If (a variable) is declared in a while test or a for statement, then it is scoped to the end of the following sub-statement." This is a great clue but it doesn't actually clarify that for-statements are scopes.
In particular, we can demonstrate that in glslang, for-statements are scopes even when they do not declare any variables at all:
void main() {
int x=1; for (;;) int x=2;
}
This compiles in glslang.
from glsl.
Related Issues (20)
- Another descriptor binding model (new data type idea)
- Symbolic/Automatic Differentiation Implementation in glsl
- Please rename default branch from 'master' to 'main' per Khronos policy HOT 4
- Clarify "Boolean expression" for binary logical operators HOT 7
- Support for Vertex/Fragment layout blocks
- Is GLSL had some online document? HOT 2
- Khronos GLSL grammar 4.60.7 has missing parameter-type for "P" in "textureGrad" HOT 2
- GLSL grammar allows for statements like "float;" but does not say they're invalid HOT 1
- GL_KHR_cooperative_matrix.txt not public HOT 1
- Vulkan reserved keywords are missing from the GLSL ES 3.2 Spec HOT 1
- GLSL Specification 4.60.8: incorrect formatting HOT 1
- halfBitsToUInt16 is missing HOT 4
- GL_EXT_shader_explicit_arithmetic_types misspelling of halfBitsToUInt16?
- GL_KHR_vulkan_glsl allows gl_VertexIndex in any stage
- [GLSL 4.6 Specification] Clarify the translation from UTF-8 scalar values to the corresponding character set tokens HOT 3
- GLSL_NV_mesh_shader.txt lacks a figure (figure 3.1)
- Clarify compilation of unbound array
- Description of texelFetch erroneously implies the lod parameter can be omitted HOT 1
- Variables of opaque types should be allowed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glsl.