-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Variable named ∇x
gives "unknown start of token" compiler error
#120142
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
Comments
See rust-lang/rfcs#3402 and https://www.unicode.org/reports/tr31/proposed.html#Mathematical_Compatibility_Notation_Profile @rustbot label T-lang -C-bug C-enhancement |
This would need an RFC to extend the current identifier profile (the default one from UAX 31) to use the mathematical notation profile. This would add these characters to the identifier profile (with the superscripts and subscripts not being allowed at the beginning of an identifier) All of these would get linted on by the uncommon_codepoints lint since they have (A change I want to make is for |
Hey if were getting mathematical characters can i just say i would really love it if we had Also what about the emoji profile 😀 |
There isn't for the math operators because those are considered operatorlike. As for emoji it's unlikely. Rust would have to put together its own set. Emoji identifiers are a complicated can of worms. |
Personally I'd be interested in math operators at least tokenizing, so they could reach macros as |
mathematical notation profile support would be great - It would be very helpful that subscript and superscript numbers are allowed to be used as identifiers ( E.g. |
If you want this, write an RFC for it. |
simply RFC this to unicode |
No, the mathematical notation profile is Unicode's solution to this problem. It allows consumers of the specification, like Rust, to make this type of choice on its own merits. Writing further proposals to Unicode would not be productive. |
I tried this code:
I expected the code to compiles but instead I get the compiler error message "unknown start of token \u{2207}".
This is surprising as variable names starting with Greek letters are fine:
I believe the cause is that Rust identifiers need to start with a
XID_Start
unicode characters, however the "Nabla" ∇ (0x2207) does not seem to be on that list.It would be great to have the "Nabla" operator as a valid start token for identifier as it very commonly used in physics and mathematics to denote the derivative of a multi-variable function.
A possible workaround is to use the "Canadian syllabics e" ᐁ (0x1401).
The text was updated successfully, but these errors were encountered: