evanw / glslx

A GLSL type checker, code formatter, and minifier for WebGL
http://evanw.github.io/glslx/
MIT License
411 stars 28 forks source link

Including the same file multiple times causes errors #15

Closed ryankaplan closed 4 years ago

ryankaplan commented 4 years ago

Hi Evan!!!

I have files with a dependency chain like this...

This is a problem because main indirectly includes two copies of random.glslx which causes syntax errors. I remember you calling this out when you implemented include statements, but now I want to fix it :)

The way include statements currently work is that the parser replaces them with the content of the file that they reference. I think we could "fix" this by having it do this only for the first include it encounters for a particular file.

Are you open to a pull request that does this? Can you think of any reasons why it wouldn't work or would be hard? LMK!