-
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
Support importing the parent directory - bring "./"
#4276
Comments
P2/P3 |
This pull request adds support for bringing directories. Bringing a directory will make all types defined in the files in a directory accessible through the alias defined by the user: ``` bring "./aws" as aws; ``` If a symbol like "Bucket" is defined multiple times inside files at the same hierarchical level of "aws", an error will be raised saying that there are multiple definitions of "Bucket" inside the directory. If the directory contains subdirectories, it will be available through a child namespace inside `aws`. For example, `aws.storage` will contain types from all `aws/storage/*.w` files. To achieve this, I had to figure out some way to model symbol lookups in a directory, where there might be multiple symbol environments that have to be looked up before finding a symbol. To that end, I changed `Namespace` so instead of storing a single single environment, it stores a vector of symbol environments, as this seemed like the least invasive change. Future items: - #4276 ## 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)*.
Hi, This issue hasn't seen activity in 60 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
Hi, This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
Hi, This issue hasn't seen activity in 90 days. Therefore, we are marking this issue as stale for now. It will be closed after 7 days. |
Feature Spec
It should be possible to reuse other modules classes and public types from the current directory:
Use Cases
Reduce the number of
bring
statements in folders with lots of modulesImplementation Notes
Currently this doesn't work because the compiler sees a cyclic dependency where
src/file1.w
depends onsrc/
which depends onsrc/file1.w
.One possible way to break this dependency cycle could be treat these self-directory imports differently, e.g. so
src/file1.w
depends onsrc/#1
andsrc/#1
is a special node that depends on all of its children files/directories EXCEPT forsrc/file1.w
. (just the first idea off the top of my head, not sure if this is a good one)Component
Compiler
Community Notes
The text was updated successfully, but these errors were encountered: