-
Notifications
You must be signed in to change notification settings - Fork 200
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
feat(compiler)!: interfaces, enums, and public classes must be defined at the top-level #7036
Conversation
Thanks for opening this pull request! 🎉
|
Console preview environment is available at https://wing-console-pr-7036.fly.dev 🚀 Last Updated (UTC) 2024-08-20 23:03 |
BenchmarksComparison to Baseline 🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜ Within 1.5 standard deviations Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI. Results
Last Updated (UTC) 2024-08-20 23:08 |
Thanks for contributing, @Chriscbr! This PR will now be added to the merge queue, or immediately merged if |
Congrats! 🚀 This was released in Wing 0.83.0. |
+1 not to do this for classes at the moment. |
Closes #7035
Closes #5542
To encourage more readable code and reduce the number of edge cases we might have to handle in the compiler implementation, we add the constraint that that interfaces, enums, and any exported classes have to be defined at the top level. This requirement is already in place for structs.
It's a bit unclear whether we want to apply the same restriction to classes, since classes can have code inside of them (unlike interfaces, enums, and structs) and you can certainly find plenty of examples where folks define anonymous classes inside functions in other languages, so for now we're continue to allow them, though support for it isn't as rigorously tested. We only require that if you define a class in a local context, it must be private, since it wouldn't be possible to access them in other Wing files.
BREAKING CHANGE: interfaces, enums, and classes marked with "pub" or "internal" are now required to be defined at the top-level of Wing programs. Please let us know if you encounter issues due to this change.
Checklist
pr/e2e-full
label if this feature requires end-to-end testingBy submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.