Skip to content

Are there any plans to support Unicode as a variable name? #1283

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

Closed
qcks opened this issue Nov 2, 2020 · 11 comments
Closed

Are there any plans to support Unicode as a variable name? #1283

qcks opened this issue Nov 2, 2020 · 11 comments
Labels
request Requests to resolve a particular developer problem

Comments

@qcks
Copy link

qcks commented Nov 2, 2020

Are there any plans to support Unicode as a variable name?

@devoncarew
Copy link
Member

cc @lrhn

@lrhn lrhn transferred this issue from dart-lang/sdk Nov 3, 2020
@lrhn lrhn added the request Requests to resolve a particular developer problem label Nov 3, 2020
@lrhn
Copy link
Member

lrhn commented Nov 3, 2020

No current plans, no.

It's not an unreasonable idea, but it has also not been a big priority. It will affect parsing time (currently non-ASCII characters can only occur inside comments and string literals in a valid Dart program, which makes tokenization simpler. It doesn't have to recognize whether a sequence of bytes is a Unicode identifierStart/identifierPart or not, something which requires a potentially large table to figure out).

@mateusfccp
Copy link
Contributor

I'm looking forward to name my variables with emojis.

@lrhn
Copy link
Member

lrhn commented Nov 3, 2020

I'm fairly sure pictographic characters are not considered identifier characters, so I wouldn't expect var 🎄 = 🌲 + ⭐ ; to become reality. Too bad, var 🦄 🌈 = false;.

@munificent
Copy link
Member

I specifically think we should not support arbitrary Unicode letters in identifiers. There are too many homoglyphs which can make code confusingly wrong at best or mask deliberate security bugs at worst.

@boukeversteegh
Copy link

I specifically think we should not support arbitrary Unicode letters in identifiers. There are too many homoglyphs which can make code confusingly wrong at best or mask deliberate security bugs at worst.

Sounds like a problem area indeed, but on the other hand, it would only be the concern to those developers choosing to use non-ascii identifiers. Have you ever run into this issue @qcks in another programming language, and if so, how do you tend to avoid this?

@qcks
Copy link
Author

qcks commented Nov 16, 2020

I specifically think we should not support arbitrary Unicode letters in identifiers. There are too many homoglyphs which can make code confusingly wrong at best or mask deliberate security bugs at worst.

Sounds like a problem area indeed, but on the other hand, it would only be the concern to those developers choosing to use non-ascii identifiers. Have you ever run into this issue @qcks in another programming language, and if so, how do you tend to avoid this?

Simply put, the variable names are long and smelly.

@miaosun009
Copy link

I want to have that characteristic

@munificent
Copy link
Member

it would only be the concern to those developers choosing to use non-ascii identifiers.

The way developers work today with massive open source ecosystems, package managers, and deep dependency graphs, we are all using lots of lots of code that we don't have much control over.

@feinstein
Copy link

I think this can lead to pranks, where people could sneak in some invisible characters into someone else's work and make them spend a good while trying to figure out why the analyzer is complaining. +1 for security concerns.

@munificent
Copy link
Member

I'm going to go ahead and close this because the language team has no plans to do this. If at some point in the future we do decide to consider it, we can always reopen the bug, but I think that's relatively unlikely. Homoglyph attacks and the recent Trojan Source exploit lean strongly towards preferring code source code to be as regular and simple as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
request Requests to resolve a particular developer problem
Projects
None yet
Development

No branches or pull requests

8 participants