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

fix(compiler): cannot chain ?? expressions #5987

Merged
merged 3 commits into from
Mar 19, 2024
Merged

Conversation

Chriscbr
Copy link
Contributor

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

  • Title matches Winglang's style guide
  • Description explains motivation and solution
  • 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.

@Chriscbr Chriscbr requested a review from a team as a code owner March 18, 2024 21:12
Copy link

Thanks for opening this pull request! 🎉
Please consult the contributing guidelines for details on how to contribute to this project.
If you need any assistence, don't hesitate to ping the relevant owner over Slack.

Topic Owner
Wing SDK and utility APIs @chriscbr
Wing Console @ainvoner, @skyrpex, @polamoros
JSON, structs, primitives and collections @hasanaburayyan
Platforms and plugins @hasanaburayyan
Frontend resources (website, react, etc) @tsuf239
Language design @eladb
VSCode extension and language server @markmcculloh
Compiler architecture, inflights, lifting @yoav-steinberg
Wing Testing Framework @tsuf239
Wing CLI @markmcculloh
Build system, dev environment, releases @markmcculloh
Library Ecosystem @chriscbr
Documentation @hasanaburayyan
SDK test suite @tsuf239
Examples @hasanaburayyan
Wing Playground @eladcon

@Chriscbr Chriscbr mentioned this pull request Mar 18, 2024
5 tasks
@monadabot
Copy link
Contributor

monadabot commented Mar 18, 2024

Console preview environment is available at https://wing-console-pr-5987.fly.dev 🚀

Last Updated (UTC) 2024-03-18 21:31

@monadabot
Copy link
Contributor

monadabot commented Mar 18, 2024

Benchmarks

Comparison to Baseline ⬜⬜🟥⬜⬜⬜🟥⬜⬜⬜⬜⬜⬜
Benchmark Before After Change
version 61ms±2.42 59ms±0.72 -2ms (-3.07%)⬜
empty.test.w -t sim 485ms±4.63 488ms±2.99 +3ms (+0.61%)⬜
empty.test.w -t tf-aws 700ms±4.89 723ms±9.3 +23ms (+3.27%)🟥
hello_world.test.w -t sim 511ms±5.02 523ms±6.44 +12ms (+2.4%)⬜
hello_world.test.w -t tf-aws 1640ms±10.04 1656ms±7.39 +16ms (+0.98%)⬜
functions_10.test.w -t sim 589ms±8.14 603ms±8.83 +14ms (+2.41%)⬜
functions_10.test.w -t tf-aws 2210ms±10.37 2259ms±18.63 +49ms (+2.2%)🟥
jsii_small.test.w -t sim 499ms±4.92 496ms±3.04 -3ms (-0.61%)⬜
jsii_small.test.w -t tf-aws 717ms±3.19 720ms±6.26 +4ms (+0.5%)⬜
jsii_big.test.w -t sim 2926ms±28.35 2931ms±8.68 +5ms (+0.16%)⬜
jsii_big.test.w -t tf-aws 3182ms±12.8 3179ms±24.36 -3ms (-0.09%)⬜
functions_1.test.w -t sim 528ms±5.76 535ms±7.27 +7ms (+1.3%)⬜
functions_1.test.w -t tf-aws 965ms±6.49 960ms±11.12 -4ms (-0.43%)⬜

⬜ Within 1.5 standard deviations
🟩 Faster, Above 1.5 standard deviations
🟥 Slower, Above 1.5 standard deviations

Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI.

Results
name mean min max moe sd
version 59ms 58ms 61ms 1ms 1ms
empty.test.w -t sim 488ms 480ms 495ms 3ms 4ms
empty.test.w -t tf-aws 723ms 703ms 743ms 9ms 13ms
hello_world.test.w -t sim 523ms 509ms 539ms 6ms 9ms
hello_world.test.w -t tf-aws 1656ms 1639ms 1670ms 7ms 10ms
functions_10.test.w -t sim 603ms 586ms 618ms 9ms 12ms
functions_10.test.w -t tf-aws 2259ms 2237ms 2327ms 19ms 26ms
jsii_small.test.w -t sim 496ms 488ms 503ms 3ms 4ms
jsii_small.test.w -t tf-aws 720ms 707ms 737ms 6ms 9ms
jsii_big.test.w -t sim 2931ms 2917ms 2956ms 9ms 12ms
jsii_big.test.w -t tf-aws 3179ms 3128ms 3215ms 24ms 34ms
functions_1.test.w -t sim 535ms 518ms 552ms 7ms 10ms
functions_1.test.w -t tf-aws 960ms 933ms 986ms 11ms 16ms
Last Updated (UTC) 2024-03-18 21:37

@monadabot monadabot added the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Mar 18, 2024
Copy link
Contributor

@yoav-steinberg yoav-steinberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@yoav-steinberg yoav-steinberg removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Mar 19, 2024
Copy link
Contributor

mergify bot commented Mar 19, 2024

Thanks for contributing, @Chriscbr! This PR will now be added to the merge queue, or immediately merged if rybickic/unwrap-or2 is up-to-date with main and the queue is empty.

mergify bot added a commit that referenced this pull request Mar 19, 2024
@mergify mergify bot merged commit 234d633 into main Mar 19, 2024
15 checks passed
@mergify mergify bot deleted the rybickic/unwrap-or2 branch March 19, 2024 07:51
@monadabot
Copy link
Contributor

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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to chain null coalescing operator (??)
4 participants