[C] Bug with “register” keyword
I just spent hours banging my head off the table because of this. I forgot that the word register is a keyword when writing C code. Clang and gcc both kept throwing totally random errors when I was writing the function void print_single_register(char *register, pid_t child_pid);. I finally brought the function into Xcode which showed register in the keyword color. It turns out that Sublime will not recognize it as a keyword if it comes after the type definition, only if it comes before the type definition like it should (register int i = 0;). This is most likely a bug in the definition of the C syntax highlighting built into Sublime. The “C Improved” syntax definition I have installed through Package Manager highlights it correctly. First screenshot is the built in C syntax, second is “C Improved"
I haven't written any C in years, so I could be wrong. But isn't the example code invalid?
void print_single_register(char *register, pid_t child_pid);
Will this compile, or will it cause a compile-time error?
If it's an error, then there is definitionally no correct way to highlight it. In that context, register isn't a keyword, it's an invalid token. So it sounds like the underlying issue is that the line is highlighted as though it were valid and register were a parameter name, but because it is not valid you would like register to be highlighted so that it stands out. Is this correct?
https://en.wikipedia.org/wiki/Register_(keyword)
@Thom1729 , correct, that is invalid code because register is a keyword and can’t be used as a variable name. Also correct, it would’ve been much easier to find the error had it been highlighted as a keyword. It was just one of those things that I knew in the back of my head that it was a keyword but totally forgot until I brought it into Xcode and it ended up showing it like this:

The way the C improved package shows it is perfect as well. Just makes it way easier to see the bug at hand vs the useless clang error expected )
I think that if we were to introduce special highlighting for invalid parameter names (which I don't have a position on, not being familiar with the C syntax definition), we would go with the invalid.illegal scope, which should make it stand out like a sore thumb. Would this work just as well or better?

Python uses invalid.illegal.name.python btw.
This is something that modes are generally pretty inconsistent on, and I think should be broadly improved. The Scala mode, for example, has some catching of reserved words in identifiers, but it isn't universal. I think that's partially because it's so easy to make an {{identifier}} regex reference that you use everywhere, but much harder to remember to add the - match: '{{reserved_word}}' right above it in every location.
I think invalid.illegal would probably work just as well and probably make more sense in the grand scheme of things. But honestly anything to make it clearer would be much appreciated
Try out https://github.com/sublimehq/Packages/pull/1831 It should highlight it correctly.
@ismell I either installed the changes you made incorrectly (likely) or that didn't work.
Here is what it looks like for me.

@ismell Just noticed it was my theme not properly coloring it. Thanks for the work!