-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[D] Add highlighting for recognised __traits/pragmas #3963
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A certain identifier not being supported by a compiler (causing compiler errors) may not directly be equal to invalid syntax.
In general being too over-eager may be annyoing to end users due to seeeing tons of red (illegal highlighted) code all the time while editing code.
That's however too late to question for D anyway though.
Valid Like I noted, unrecognised |
A synatx definition should highlight tokens and ideally handle incomplete token/statements in sane ways to create the impression of it already knowing what's up next. It is not necessarily required to do a linter's job. Even though the compiler isn't happy with a certain token, currently, support for new ones may be added at any time. So unsupported pragmas are not a syntax error. The compiler's parser would also read the full token, but just throw an error at a later point, as it doesn't know it. |
Yes, pragmas are designed to accommodate compiler-specific identifiers, so my PR already accounts for the fact that their identifiers are arbitrary by just ignoring unrecognised identifiers. Traits, on the other hand, are defined as an exhaustive list of keywords. A traits expression, by definition, must use one of these keywords. Yes, new keywords may be added, but the same holds for every other aspect of the language's syntax. |
Changes:
__traits
are highlighted withconstant.other.d
.__traits
now triggerinvalid.illegal.d
, because they cause compile errors.constant.other.d
. Invalid pragmas are not meant to cause compile errors in D (currently they do, but it's being fixed), so they do NOT triggerinvalid.illegal.d
.