-
-
Notifications
You must be signed in to change notification settings - Fork 21.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDShader allows commas in for
conditions (middle part) incorrectly
#95451
Comments
I think this is not a bug, because middle expression commas are allowed on GLSL and C-language family. Only a last expression has been taken into account in such case + if we change it - this will cause a compatibility breakage.
It makes sense, would you like to create a new issue about it? |
@Chaosus It is still an issue because, even if you go the route of allowing comma operator semantics only in You should only require the last comma part to be a boolean, the others could be anything because their return value is ignored.
|
So, to clarify, this valid code is accepted: Btw, if you go the route of allowing comma operator semantics even in while (i = f(i), i < n) foo();
do foo(); while (i = f(i), i < n); |
Tested versions
System information
Godot v4.2.2.stable (15073af) - Freedesktop SDK 23.08 (Flatpak runtime) - X11 - Vulkan (Forward+) - integrated Intel(R) HD Graphics 5500 (BDW GT2) () - Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz (4 Threads)
Issue description
GDShader is allowing commas in
for
middle part (condition), requiring every comma-separated part to be a boolean operator. Since GDShader (thankfully!) doesn't have a "comma operator" like in GLSL, this has to be a bug.The compiler should either:
for
, while still allowing it on 1st part (to declare multiple variables) and on 3rd part (to run multiple instructions, e.g. to doi++, j++
). This is consistent withwhile
, which does NOT allow commas.,
PROPERLY with comma operator semantics, so only the last comma-separated part has to be a boolean in a condition area. But I'm strongly against adding a comma operator that works everywhere, as it's a very confusing syntax. It's only actually useful in the 3rd part offor
.Additionally, I don't understand why the
for
condition part requires a boolean operator. It makes more sense to allow any expression returning a boolean, e.g. some bool function, some bool variable, literalstrue
andfalse
, etc.Steps to reproduce
buggy.gdshader
Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered: