Skip to content

Parse error when defining struct fields: unexpected TYPE_NAME, expecting IDENTIFIER #3931

Description

@laurentlb

Hi,

This code leads to a parse error:

#version 400
struct B
{
    vec3 t;
};
struct K
{
    float A, B; // parse error here
};
void main(){}
glslang.exe .\test.frag
ERROR: 0:8: '' :  syntax error, unexpected TYPE_NAME, expecting IDENTIFIER
ERROR: 1 compilation errors.  No code generated.

To workaround this error, I can either:

  • rename the field B (so that it's not the same name as the first struct;
  • or split the line into float A; float B;
  • or switch the order of fields: float B, A;

So the parse error happens when I define multiple fields of the same type, and one of them (except the first one) has the same name as a struct define above.

For the context, I'm working on a shader minifier, so using single-letter names is useful.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions