Error: not a swizzle with custom struct
jroessel opened this issue · comments
For the following code:
struct S{
vec2 p1;
vec2 cp1;
vec2 cp2;
vec2 p2;
};
vec2 calc(S points, float t) {
vec4 m1m2 = mix(vec4(points.p1, points.cp1), vec4(points.cp1, points.cp2), t);
return m1m2.xy;
}
and the following options:
--format indented --preserve-all-globals --preserve-externals --no-sequence --no-remove-unused
I get an error
not a swizzle (c)
This was a bit hard to find, as it happened somewhere in a larger shader snippet (location information for errors would be great!). It appears as if swizzleIndex
is called with the right-hand side of points
, even though this should have been guarded by isFieldSwizzle
.
Oh, wait, it might not be in dropLastSwizzle
.
Thanks for the report, this should be easy to fix.
dropLastSwizzle
is missing a check for isFieldSwizzle
.
Perhaps moving that check to renameField
is a bit safer in the long run. I'd attempt a fix here, but I think the total amount of F# code I've ever written amounts to perhaps 100 lines or so, without much understanding.