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): can't define optional function types #5455

Merged
merged 7 commits into from
Jan 18, 2024

Conversation

yoav-steinberg
Copy link
Contributor

See #4296
We can now define optional function types via support for parenthesis around type annotations:

// Optional function type
var let fn: (():void)? = () => { };
fn = nil;
// Crazy parenthesis type annotation
let x: (((((((num))))))) = 1;

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.

done via support for parenthesis around type annotations
@yoav-steinberg yoav-steinberg requested a review from a team as a code owner January 17, 2024 13:24
@monadabot
Copy link
Contributor

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 @skorfmann
Wing Playground @eladcon

@monadabot
Copy link
Contributor

monadabot commented Jan 17, 2024

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

Last Updated (UTC) 2024-01-18 14:14

@monadabot
Copy link
Contributor

monadabot commented Jan 17, 2024

Benchmarks

Comparison to Baseline 🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
Benchmark Before After Change
version 73ms±0.66 76ms±1.29 +3ms (+4.39%)🟥
jsii_big.test.w -t sim 3375ms±12.99 3389ms±12.08 +14ms (+0.42%)⬜
jsii_big.test.w -t tf-aws 3494ms±13.01 3487ms±14.32 -8ms (-0.22%)⬜
functions_1.test.w -t sim 621ms±4.46 625ms±4.54 +4ms (+0.71%)⬜
functions_1.test.w -t tf-aws 1850ms±97.88 1844ms±69.11 -7ms (-0.36%)⬜
hello_world.test.w -t sim 630ms±6.93 629ms±8.64 -1ms (-0.16%)⬜
hello_world.test.w -t tf-aws 4850ms±25.27 4871ms±22.9 +20ms (+0.42%)⬜
functions_10.test.w -t sim 698ms±6 699ms±4.6 +2ms (+0.25%)⬜
functions_10.test.w -t tf-aws 4192ms±13.58 4183ms±18.93 -9ms (-0.22%)⬜
jsii_small.test.w -t sim 595ms±5.07 600ms±5.08 +6ms (+0.93%)⬜
jsii_small.test.w -t tf-aws 715ms±6.29 718ms±5.14 +3ms (+0.47%)⬜
empty.test.w -t sim 593ms±5.96 598ms±4.64 +5ms (+0.86%)⬜
empty.test.w -t tf-aws 707ms±4.96 714ms±8.83 +7ms (+0.95%)⬜

⬜ 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 76ms 74ms 80ms 1ms 2ms
jsii_big.test.w -t sim 3389ms 3367ms 3418ms 12ms 17ms
jsii_big.test.w -t tf-aws 3487ms 3457ms 3509ms 14ms 20ms
functions_1.test.w -t sim 625ms 614ms 633ms 5ms 6ms
functions_1.test.w -t tf-aws 1844ms 1701ms 1964ms 69ms 97ms
hello_world.test.w -t sim 629ms 613ms 650ms 9ms 12ms
hello_world.test.w -t tf-aws 4871ms 4810ms 4912ms 23ms 32ms
functions_10.test.w -t sim 699ms 693ms 709ms 5ms 6ms
functions_10.test.w -t tf-aws 4183ms 4147ms 4227ms 19ms 26ms
jsii_small.test.w -t sim 600ms 583ms 606ms 5ms 7ms
jsii_small.test.w -t tf-aws 718ms 705ms 727ms 5ms 7ms
empty.test.w -t sim 598ms 588ms 612ms 5ms 6ms
empty.test.w -t tf-aws 714ms 699ms 735ms 9ms 12ms
Last Updated (UTC) 2024-01-18 14:23

Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Thank you lord

tools/hangar/__snapshots__/invalid.ts.snap Show resolved Hide resolved
libs/wingc/src/parser.rs Show resolved Hide resolved
@Chriscbr
Copy link
Contributor

@yoav-steinberg Can you check if this fixes #3115?

Copy link
Contributor

mergify bot commented Jan 18, 2024

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

mergify bot added a commit that referenced this pull request Jan 18, 2024
mergify bot added a commit that referenced this pull request Jan 18, 2024
@mergify mergify bot merged commit e6b1a83 into main Jan 18, 2024
15 checks passed
@mergify mergify bot deleted the yoav/parenthesis_types branch January 18, 2024 14:36
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.54.44.

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

Successfully merging this pull request may close these issues.

Unable to declare a function signature that returns an optional function
4 participants