Skip to content

Adds 'symbol constraints' for easier checking of assignments. #5170

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
wants to merge 1 commit into from

Conversation

jbondc
Copy link
Contributor

@jbondc jbondc commented Oct 8, 2015

I'll work on a proposal to explain what this solves:

SymbolConstraints

  • Adds extra bits since none left in SymbolFlags
  • Gives an easy way to check assignments to something that is notWritable

Fixes #2215
Solves: #2456, #12, ?

ConstValue

  • Gives some knowledge that a Node has a constant value.

Gives extra bits alternative to using SymbolFlags.
@jbondc
Copy link
Contributor Author

jbondc commented Oct 8, 2015

Just realized that enums don't allow assignments:
image

Assignments to property access in enums is disallowed but indexed access is ok:
image

Is that intentional? I'd expect the enum to be writable since you can do that at runtime.

The const enum doesn't exist so notWritable.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 8, 2015

As the comment mentioned, the 1.0 compiler did not do that, we did not want to introduce a breaking change. we also left indexed access to be a "escape hatch" from the type checking per se.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 8, 2015

I do not think this is the correct approach. the check should be done in "checkReferenceExpression" in "isReferenceOrErrorExpression" checking that a const enum element access expression is not a valid left hand side expression

@mhegazy
Copy link
Contributor

mhegazy commented Oct 8, 2015

i will close this one, please resubmit with changes to checkReferenceExpression.

@mhegazy mhegazy closed this Oct 8, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants