-
Notifications
You must be signed in to change notification settings - Fork 196
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 bring modules more than once #3605
Conversation
Signed-off-by: monada-bot[bot] <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing!
Signed-off-by: monada-bot[bot] <[email protected]>
+1 from me. I think a convention based on the file name seems pretty good as far as options go. Since most source files in larger Wing projects will be non-entrypoint files, I think any extra rules or annotations required from the user should be added to the entrypoint files, not the non-entrypoint files - if that makes any sense. |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Congrats! 🚀 This was released in Wing 0.24.53. |
Hey, this PR caused an issue in the LSP. We had to revert Learn and Play to a previous version. See the Slack convo https://winglang.slack.com/archives/C04QQD2SDM2/p1690534520811589. We'll have to revert this PR or fix whatever problem there is. |
Let's revert for now so newer releases will not break the playground again |
Here's the revert PR #3641 |
The PR #3605 caused an issue with the LSP.
Re-roll of the changes in #3605, but with more care taken to support the language server. The previous version of this PR introduced some bugs where the LSP was using the text from disk instead of the text in the user's editor, resulting in invalid text completions and crashes. To fix this, I had to rethink the original multi-file parsing solution so that we store the latest file text from the LSP in memory. ---- Refactors how the Wing compiler handles `bring` for local Wing files in order to support more complex `bring` use cases, like allowing multiple files to `bring` the same module. The high level implementation approach is instead of generating a single, monolithic AST, we augment the parser so that after a Wing source file is parsed, an isolated AST and a list of dependent Wing files is produced. Using this, we can write a function that parses an entire Wing program given an entrypoint, and use the `petgraph` crate to produce topological ordering of the files for type checking, and each AST is independently type checked. Fixes #3511 Fixes #3578 Fixes #3509 ## 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) - [x] 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)*.
Refactors how the Wing compiler handles
bring
for local Wing files in order to support more complexbring
use cases, like allowing multiple files tobring
the same module.The high level implementation approach is instead of generating a single, monolithic AST, we augment the parser so that after a Wing source file is parsed, an isolated AST and a list of dependent Wing files is produced. Using this, we can write a function that parses an entire Wing program given an entrypoint, and use the
petgraph
crate to produce topological ordering of the files for type checking, and each AST is independently type checked.While this unblocks several use cases, there are still some limitations. For example, consider how it's possible for classes to recursively reference each other in TypeScript:
This doesn't work in Wing currently because each file is still type checked independently. To relax this constraint, we would need to perform symbol resolution on all files first (to identify all available types and members) before performing type checking. This kind of refactoring would be pretty large and is out of scope for this PR.
Fixes #3511
Fixes #3578
Fixes #3509
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.