atom-language-rust
atom-language-rust copied to clipboard
Macro call syntax may interfere with grammar and can break syntax highlighting for remainder of document
Seems to be caused be two lines earlier, inside the macro call, where it falsely detects a function statement fn but no function begin { and therefore takes the rest of the file as a big function definition. And that's where it gets hard. The syntax of a macro call is defined by the macro definition - grammar rules can't tokenize that dynamically. One option would be to remove any tokenization inside macro calls, but that might look even worse.
I don't know any good solution to this problem atm. Anybody else?
Just thought I'd chime in and let you know I ran into this in vscode, which uses this grammar. Gluon has a record! macro where you write type Type => some_type, and it causes the same problem. Here is an example https://github.com/gluon-lang/gluon/blob/master/repl/src/repl.rs#L469
BTW does GitHub also use this grammar for syntax highlighting? Seems to have the same issues.
Yes, seeing my code highlight incorrectly on GitHub is how I noticed this.