-
Notifications
You must be signed in to change notification settings - Fork 198
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
fix(compiler): no error when trying to reassign to a let
variable
#1196
Conversation
Also correctly import reassignability (let/var) from JSII class properties.
let
variable.let
variable.
let
variable.let
variable
Note that this is currently failing because one of our tests attempt to write to an argument passed to a function, but there's currently no way of specifying if an argument is reassignable:
Should we suppor the following syntax to fix this? @eladb @Chriscbr WDYT?
See related TypeScript and Kotlin discussions |
@yoav-steinberg I'd be okay adding that syntax later if there is demand for it, though I feel like it's generally safer for parameters to not be reassignable by default. |
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.
One suggestion to reduce some verbosity - otherwise LGTM. I like the var argument idea as well 👍
Also, can you update the spec to mention this feature as well? We should keep it in sync 👍 |
* Replaced `VariableKind` with a `reassignable` bool for clarity. * Support JSII imported mutable fields via "reassignable". * Allow assigning to non-reassingbale fields in `init` for class initialization.
Signed-off-by: github-actions <[email protected]>
Update: fixed everything related to to function arguments not being |
let
variablelet
variable
let
variablelet
variable
@yoav-steinberg is this ready to be merged? |
Co-authored-by: Chris Rybicki <[email protected]>
Not yet, I woke up this morning having a feeling this might break:
|
Congrats! 🚀 This was released in Wing 0.4.121. |
now this:
produces something like:
Error at ../../examples/tests/invalid/reassing_to_nonreassignable.w:2:1 | Variable x is not reassignable
Also correctly import reassignability (let/var) from JSII class properties.
see #1186
By submitting this pull request, I confirm that my contribution is made under the terms of the
Monada Contribution License.