-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
Unhandled edge cases for cast/assignment to vector type #1215
Comments
Yeah, looks bad. |
Should be fixed now. |
Thanks. I think the implicit scalar broadcast cast should be explicit instead. This should better signify intent to actually do a broadcast, and prevent accidentally assigning or passing a scalar where a vector is expected. |
That would break things like int[<3>] x = foo();
int[<3>] y = x * 3 + 1;
// int[<3>] y = x * (int[<3>])3 + (int[<3>])1; |
It should break this, scaling is the only operator that makes sense mathematically ("ah yes, let me add 1 to a vector"). I'd rather it be |
I think this is fine in GLSL though? |
True, but it's important to note that for GLSL the implicit cast is only legal for operators, meaning you can't assign or pass a scalar to a vector (see https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.pdf Section 5.9). |
If we think about how casts work:
So this is problematic in reversing how "generous" the rules are in the particular case of scalar -> vector conversion. This special case will also likely affect how one would write macros. For example we would have |
For what it's worth, HLSL always does the scalar conversion: https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf |
Cast/assignment to vector has some unhandled edge cases:
The text was updated successfully, but these errors were encountered: