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): imported JSII types are considered defined after other types (and can't be referenced by them) #6221

Merged
merged 8 commits into from
Apr 12, 2024

Conversation

yoav-steinberg
Copy link
Contributor

@yoav-steinberg yoav-steinberg commented Apr 12, 2024

Fixes #6209
Related to #5683
Removed the statement index from JSII import spec so everything imported from a JSII module is considered define at the top level of the file. This makes types imported from JSII behave the same way as other types since #5683.

Note there's still a difference between how imported JSII types and other types behave in regards to whether they can be used before being defined: classes. In #5683 we avoided hoisting class types to the "top of the file" so you can't do something like:

new X(); // Error `X` not defined
class X {}

But this PR makes JSII classes hoisted to the top so for them this will work:

new jsii_module.X();
bring jsii_module;

I think in the long run the desired behavior is to hoist all class types. So I'm fine with this currently only working for JSII.

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.

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 @chriscbr
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

@monadabot
Copy link
Contributor

monadabot commented Apr 12, 2024

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

Last Updated (UTC) 2024-04-12 11:18

@monadabot
Copy link
Contributor

monadabot commented Apr 12, 2024

Benchmarks

Comparison to Baseline 🟥⬜⬜⬜⬜⬜⬜⬜🟩⬜🟩⬜⬜
Benchmark Before After Change
version 58ms±0.51 61ms±0.77 +3ms (+4.87%)🟥
functions_1.test.w -t sim 385ms±5.67 397ms±5.86 +12ms (+3.16%)⬜
functions_1.test.w -t tf-aws 818ms±2.61 838ms±12.23 +20ms (+2.43%)⬜
hello_world.test.w -t sim 390ms±5 394ms±12.99 +4ms (+1.12%)⬜
hello_world.test.w -t tf-aws 1500ms±7.65 1511ms±15.88 +12ms (+0.79%)⬜
jsii_big.test.w -t sim 2773ms±13.43 2777ms±15.49 +4ms (+0.13%)⬜
jsii_big.test.w -t tf-aws 3010ms±18.18 3008ms±17.4 -2ms (-0.05%)⬜
functions_10.test.w -t sim 484ms±8.72 475ms±8.29 -9ms (-1.86%)⬜
functions_10.test.w -t tf-aws 2178ms±14.15 2133ms±12.87 -45ms (-2.08%)🟩
jsii_small.test.w -t sim 367ms±4.84 365ms±3.08 -1ms (-0.31%)⬜
jsii_small.test.w -t tf-aws 617ms±6.16 604ms±1.82 -13ms (-2.11%)🟩
empty.test.w -t sim 360ms±3.69 362ms±4.84 +2ms (+0.64%)⬜
empty.test.w -t tf-aws 597ms±8.86 593ms±5.67 -3ms (-0.52%)⬜

⬜ 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 61ms 60ms 63ms 1ms 1ms
functions_1.test.w -t sim 397ms 385ms 408ms 6ms 8ms
functions_1.test.w -t tf-aws 838ms 816ms 871ms 12ms 17ms
hello_world.test.w -t sim 394ms 379ms 444ms 13ms 18ms
hello_world.test.w -t tf-aws 1511ms 1491ms 1568ms 16ms 22ms
jsii_big.test.w -t sim 2777ms 2745ms 2816ms 15ms 22ms
jsii_big.test.w -t tf-aws 3008ms 2978ms 3051ms 17ms 24ms
functions_10.test.w -t sim 475ms 454ms 489ms 8ms 12ms
functions_10.test.w -t tf-aws 2133ms 2096ms 2154ms 13ms 18ms
jsii_small.test.w -t sim 365ms 358ms 374ms 3ms 4ms
jsii_small.test.w -t tf-aws 604ms 599ms 607ms 2ms 3ms
empty.test.w -t sim 362ms 351ms 372ms 5ms 7ms
empty.test.w -t tf-aws 593ms 580ms 605ms 6ms 8ms
Last Updated (UTC) 2024-04-12 11:23

@yoav-steinberg yoav-steinberg marked this pull request as ready for review April 12, 2024 11:04
@yoav-steinberg yoav-steinberg requested a review from a team as a code owner April 12, 2024 11:04
@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 Apr 12, 2024
@MarkMcCulloh MarkMcCulloh removed the ⚠️ pr/review-mutation PR has been mutated and will not auto-merge. Clear this label if the changes look good! label Apr 12, 2024
Copy link
Contributor

mergify bot commented Apr 12, 2024

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

@mergify mergify bot merged commit 5befc2c into main Apr 12, 2024
15 checks passed
@mergify mergify bot deleted the yoav/issue_6209 branch April 12, 2024 13:14
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.70.1.

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.

Unexpectd Symbol used before being defined when type is from a JSII lib
3 participants