Darkyenus / glsl4idea

A GLSL language plugin for IntelliJ IDEA
GNU Lesser General Public License v3.0
100 stars 30 forks source link

Parser crashes for shaders which attempt to override keywords such as `lowp` / `highp` #190

Open bitsauce opened 6 months ago

bitsauce commented 6 months ago

Describe the bug

I have come across a shader that causes a crash in the GLSL parser of this plugin, which makes it impossible to edit the shader (when I write a value it just reverts the keypress immediately). This shader is a bit unconventional in that it will attempt to remove the lowp and highp based on compiler defines. While this shader is probably not ideal (or maybe not even valid GLSL), it still breaks the editor which is a bit troublesome.

To Reproduce

#ifdef USE_LOWP_HIGHP
#define lowp
#define highp
#endif

void main()
{
#ifdef SOME_DEFINE
    lowp vec4 value = vec4(0, 0, 0, 0);
#endif
}

This is a minimal repro case I found for this issue. It also seems that the lowp/highp keywords have to be used inside a define themselves for this bug to trigger.

Expected behavior The plugin continue working as if the keywords were un-overridden.

Versions