Skip to content
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

Cryptic error message when parsing GLSL C-style casts (glslang error) #97

Closed
nbentyNV opened this issue Jul 15, 2017 · 2 comments
Closed
Labels
kind:enhancement a desirable new feature, option, or behavior

Comments

@nbentyNV
Copy link
Collaborator

Not a Slang issue.

imageStore(gOutput, (ivec2)crd, pixelated.bgra);

The error message I'm getting is
syntax error, unexpected RIGHT_PAREN, expecting LEFT_PAREN

@tangent-vector-personal

To be clear, C-style cast syntax isn't supported in GLSL, so glslang is correct in reporting a syntax error. The real problem is that the parse errors that glslang outputs are not very useful (this is a big down-side to their use of a parser generator).

In this case I assume Slang is in what I call "full rewriter" mode, where it doesn't even parse function bodies. This mode is what happens if Slang is being invoked with semantic off and there are no import declarations. We reproduce the input function body exactly and glslang gives a parse error.

I suspect that in the "rewriter with imports" mode (when we see at least one import, and actually do parse function bodies) this case would work by accident because the cross-compiler logic is set up to turn HLSL casts into GLSL constructor calls. This behavior is technically a bug, since it means we accept invalid GLSL, but I'm okay with us accepting a useful superset of GLSL.

The right long-term fix is for Slang to either always accept this syntax in GLSL, and validate it so that glslang never sees it, or never accept C-style casts in GLSL but report our own error message that is more clear ("GLSL does not support C-style cast syntax") to spare the user.

A useful goal for Slang would be that the user never sees a parse error from glslang.

@tangent-vector tangent-vector added kind:enhancement a desirable new feature, option, or behavior glsl labels Oct 11, 2017
@tangent-vector
Copy link
Contributor

Slang no longer accepts GLSL as an input language, so this issue is no longer relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:enhancement a desirable new feature, option, or behavior
Projects
None yet
Development

No branches or pull requests

3 participants