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
Unable to chain null coalescing operator (??
)
#1875
Labels
🐛 bug
Something isn't working
🛠️ compiler
Compiler
📜 lang-spec-impl
Appears in the language spec roadmap
Milestone
Comments
Hi, This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
Here's another use case for this: if let x = a ?? b { ... } Both
|
This was referenced Mar 18, 2024
mergify bot
pushed a commit
that referenced
this issue
Mar 19, 2024
Fixes #1875 This fixes the issue by updating the precedent rules so the operation is right-associative. For now, expressions like `a ?? b` or `a ?? b ?? c` still have to return a non-optional value (like Rust's unwrap_or), but we can consider making it more flexible / open in the way that C# or Swift allows if appropriate in the future. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [ ] Docs updated (only required for features) - [ ] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
Congrats! 🚀 This was released in Wing 0.61.17. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🐛 bug
Something isn't working
🛠️ compiler
Compiler
📜 lang-spec-impl
Appears in the language spec roadmap
Community Note
I tried this:
This doesn't work (@Chriscbr brought this up):
This works:
This is also going to be defined in the spec (#436).
I expected this:
To behave the same as JS's Nullish_coalescing operator.
Instead, this happened:
See above.
Component:
Compiler
Wing Version:
No response
Node.js Version:
No response
Platform(s):
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: