Skip to content
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

Is it possible to lock things down to string constants? #4

Closed
mikewest opened this issue Sep 21, 2017 · 3 comments
Closed

Is it possible to lock things down to string constants? #4

mikewest opened this issue Sep 21, 2017 · 3 comments
Labels

Comments

@mikewest
Copy link
Member

It would be lovely if we could have a CreateFromConstant method that would allow

Whatever.createFromConstant("https://example.com/")

but deny

var notAConstant("https://example.com/");
Whatever.createFromConstant(notAConstant);
@mikesamuel
Copy link
Collaborator

How can this be done without static analysis?

We've done reasonably reliable checks in other languages by defining an isProbablyInConstantPool predicate, but I don't know of one for JavaScript and we'd need one that's scoped to origin, realm, or narrower.

@mikesamuel
Copy link
Collaborator

Since Mike didn't mention this explicitly: https://github.com/mikewest/tc39-proposal-literals

@koto
Copy link
Member

koto commented Jun 4, 2018

Shelving this approach for now. It's proven quite difficult to change the language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants