Skip to content

Spurious swizzling of struct members #395

@therontarigo

Description

@therontarigo

Input

struct Foo {
  int field1;
  int field2;
  int wz;
  int xy;
};

out vec4 O;
void main() {
  Foo f;
  f.field1 = 1;
  f.field2 = 2;
  f.wz = 3;
  f.xy = 4;
  O.xy=vec2(f.wz,f.xy);
}

Output

struct Foo{int field1;int field2;int wz;int xy;};
out vec4 i;
void main()
{
  Foo f;
  f.field1=1;
  f.field2=2;
  f.wz=3;
  f.xy=4;
  i.xy=vec2(f.wzxy);  // uh-oh
}

Not yet encountered in practice, but anticipated when considering #393
I don't see how this can be avoided except by disallowing all struct member names that resemble vector swizzles, even when they consist of canonicalFieldNames characters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions