shader-slang / slang

Making it easier to work with shaders
http://shader-slang.com
MIT License
2.13k stars 180 forks source link

Error message underline position is not calculated correctly #5219

Open expipiplus1 opened 2 weeks ago

expipiplus1 commented 2 weeks ago

consider this file

// Single byte code points
/* abc */ aaa;
// Two byte code points
/* αβγ */ bbb;
// Single byte code points each followed by a two byte combining character
/* âb̃c⃗ */ ccc;
// Three byte code points of Wide characters
/* 救命!我被困在编译器工厂里了! */ ddd;

Notice how the error underlines are incorrectly positioned

+ build/Debug/bin/slangc -line-directive-mode none test.slang -stage compute
test.slang(2): error 39999: declaration does not declare anything
/* abc */ aaa;
          ^~~
test.slang(4): error 39999: declaration does not declare anything
/* αβγ */ bbb;
             ^~~
test.slang(6): error 39999: declaration does not declare anything
/* âb̃c⃗ */ ccc;
                 ^~~
test.slang(8): error 39999: declaration does not declare anything
/* 救命!我被困在编译器工厂里了! */ ddd;
                                                    ^~~

It's probably a losing battle trying to capture all the corner cases, but hooking up wcwidth and counting grapheme clusters might make the output look a little more pro in any sensible case

(also we should probably remove this outdated info from the docs haha

The identifier consistent of a single underscore (_) is reserved by the language and must not be used by programs. Otherwise, there are no fixed keywords or reserved words. Words that name a built-in language construct can also be used as user-defined identifiers and will shadow the built-in definitions in the scope of their definition.

)

bmillsNV commented 2 weeks ago

Leaving in backlog for now. Not critical for us to fix.