-
Notifications
You must be signed in to change notification settings - Fork 323
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
Replace all from ... export all
with explicit exports
#10369
Merged
Merged
Changes from all commits
Commits
Show all changes
112 commits
Select commit
Hold shift + click to select a range
0137a25
Replace all `from ... export all` with explicit exports
Akirathan d7362f7
Add some missing exports
Akirathan 2bf2f4f
Remove isAll and hiding fields from Export IR
Akirathan 3140aaa
Test compiler errors for missing export fields
Akirathan 4cb2bb1
Add ExportConstructorTest
Akirathan 2844901
Add ExportedSymbolsTest
Akirathan 15829b5
Add ExportCycleDetectionTest
Akirathan 2252a6f
Remove ExportCycleDetectionTest
Akirathan bad6558
Reintroduce ExportCycleDetectionTest
Akirathan 6351bc3
Add test for exported symbols in synthetic modules
Akirathan 4b34b94
Add test for export cycle detection in three modules
Akirathan 0ac44a3
Remove unnecessary imports from tests
Akirathan 6dc51f3
Test export from different module
Akirathan 87dc19d
Implement ProjectUtils.deleteRecursively
Akirathan 5148403
ProjectUtils: Main module does not have to exist when creating a project
Akirathan e428408
Remove BindingMap.SymbolRestriction
Akirathan 6937908
Force compilation in ExportedSymbolsTest
Akirathan c9f0a36
Add test for importing a constructor
Akirathan 3a00437
Add test for exporting a constructor
Akirathan 1c8ec12
ResolvedConsytructor is an ImportTarget
Akirathan 7699d17
fmt
Akirathan 3bf93ea
ResolvedMethod is ImportTarget.
Akirathan 21218cb
Fix ExportCycleDetectionTest - reported order of module is non-determ…
Akirathan c9b881d
Fix ExportStaticMethodTest.
Akirathan 02e2eb1
Enable test for module method resolution
Akirathan 3de9c67
fmt
Akirathan f457a3e
Importing symbols from methods is not allowed
Akirathan ba52b80
Export tests use `export ...` syntax instead of `from ... export ...`.
Akirathan 96d60b6
Remove syntax error from test
Akirathan 2526360
Test exports resolution graph building
Akirathan 175f18f
Test exports resolution graph for type
Akirathan 6c1db95
Rename Node.target back to Node.module
Akirathan b6ed712
Fix tests - Exports graph nodes targets only modules
Akirathan e0a682e
Move ExportsResolution to separate package
Akirathan 897f4a0
Rename Node.module to Node.target back again
Akirathan 0228f50
ExportedModule contains list of symbols
Akirathan 02481e8
Remove WIP comments from tests
Akirathan 46c678f
ResolvedMethods have self reference in their exported symbols
Akirathan 53a6d31
fmt
Akirathan 5f0fed7
ResolvedType have self reference in their exported symbols
Akirathan 62cbc9c
Remove outdated ignored tests from #6669
Akirathan 3a0a5cc
Handle renamed exports
Akirathan c0b71a8
Rename and doc update
Akirathan ef7716b
Replace `from ... export ...` with `export ...` type of export in std…
Akirathan 7ff1bf0
Replace `from ... export ...` with `export ...` type of export in Exp…
Akirathan 7a3670d
Replace `from ... export ...` with `export ...` type of export in Boo…
Akirathan 98302ac
ResolvedImport has multiple import targets
Akirathan e5a7273
Fix typo in exports in std base Main
Akirathan a346c29
ResolvedMethod's qualifiedName is consistent with imports
Akirathan 0b37f9f
ImportResolverAlgorithm deals with extension and conversion methods
Akirathan 6e0d992
Add import/export test for extension methods
Akirathan 2cab531
Add tests for exporting and importing conversion methods
Akirathan 3022f6f
Add tests for exporting and importing conversion methods
Akirathan a491703
Replace `from ... export ...` with `export ...` type in micro-distrib…
Akirathan 9143c29
In micro-distribution, replace some import all by specific imports
Akirathan b6c0765
Use specific import/exports in tests
Akirathan 2bc9042
Remove tests on export hiding
Akirathan f3d0afc
Fix Export.showCode method
Akirathan f454ac9
Remove export all from test
Akirathan fb93983
Add asert checks for consistent exported symbols
Akirathan 409fb18
Add tests for exported symbols from synthetic modules
Akirathan 0c371d2
ExportsResolution does not re-export symbols from resolved exports
Akirathan 1a8a3ae
Update functions docs
Akirathan 54299f1
Add docs for imports/exports with multiple targets
Akirathan a65ec1b
Remove resolvedExports field from BindingsMap.
Akirathan 9538ae1
ExportSymbolAnalysis iterates only some exports
Akirathan c6ddaf5
Fix ExportExtensionMethodTests
Akirathan 3e9cbeb
Fix ExportSymbolAnalysis to correctly resolve module from the export
Akirathan 3f864e4
Small refactoring
Akirathan 0916bde
ExportSymbolAnalysis is not a compiler pass.
Akirathan 03de7c6
fmt
Akirathan a84c450
Move java source from scala dir
Akirathan 6a4555b
Fix indexing errors in ExportSymbolAnalysis
Akirathan 9ca0c39
Export cycle is not detected for self-exports
Akirathan 717b47c
Refine "Exporting non-existing" symbol tests
Akirathan db4396e
ExportSymbolAnalysis handles exports with exactly 3 name items specially
Akirathan d1c9400
ExportsResolution.resolveExportedSymbols drops duplicate symbols
Akirathan 427a70f
Conflicting resolutions are reported as CompilerError.
Akirathan 142f038
Add tests for export resolution module topological sort
Akirathan 118ebb7
fmt
Akirathan 931c440
Constructors can be exported from the same module.
Akirathan fbb64d2
Add test for "importAllDoesNotImportModuleItself"
Akirathan 57ec17b
Test that import all from type does not import the type itself
Akirathan da1b75c
Fix resolution export sorting test.
Akirathan fd23f45
ResolvedType does not list itself in exportedSymbols.
Akirathan 99c8864
Use specific exports in Table/Main.enso
Akirathan f8895c9
Use specific exports in Database/Main.enso
Akirathan 7d24114
ExportSymbolAnalysis handles submodule export
Akirathan eae45af
Add ExportModuleTest
Akirathan 45d9c55
fmt
Akirathan 3e0496e
Merge branch 'refs/heads/develop' into wip/akirathan/10258-disallow-e…
Akirathan b01f526
Use specific exports in more places
Akirathan d40e0bb
Rename StaticMethod to ExtensionMethod
Akirathan 171ca2e
IrToTruffle consructs ImportExportScope from directly exported modules
Akirathan a8d8fac
Fix creation of nested submodule in ProjectUtils
Akirathan 99bb586
Update docs of benchmarks - debugging
Akirathan 194a4aa
Workaround for non-inserting synthetic imports in Database.Main
Akirathan 54e8b0a
Test importing a re-exported symbol
Akirathan 2d332ee
#10504: Ignore failing test of importing relative symbols
Akirathan c8e1b91
Add ExportResolutionOrderingTest
Akirathan 29def8b
#10505: Add comment to test why it is ignored
Akirathan 97670a3
Add helper method to ModuleUtils
Akirathan 5c0c622
Use specific exports in Deep_Export test
Akirathan bfb6d56
#10504: Ignore Deep_Export test
Akirathan 7654182
Fix ImportAndFQNConsistencyTest - use BindingsMap.exportedSymbols there.
Akirathan add8c78
fmt
Akirathan fd4f2ab
Fix error messages in ErrorCompilerTest
Akirathan 9eabbcd
Fix error messages in ErrorCompilerTest
Akirathan 8a7dcc4
Skip ExportSymbol analysis for non-compiled modules
Akirathan 5b1fd5c
Update docs
Akirathan a4aa2b6
micro-distribution exports Boolean type
Akirathan 4aca14c
Update RuntimeSuggestionUpdatesTest
Akirathan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Boolean.enso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,18 +18,22 @@ code from modules. | |
- [Import Syntax](#import-syntax) | ||
- [Qualified Imports](#qualified-imports) | ||
- [Unqualified Imports](#unqualified-imports) | ||
- [Imports with multiple targets](#imports-with-multiple-targets) | ||
- [Export Syntax](#export-syntax) | ||
- [Qualified Exports](#qualified-exports) | ||
- [Unqualified Exports](#unqualified-exports) | ||
- [Visibility of Export Bindings](#visibility-of-export-bindings) | ||
- [Implicit exports](#implicit-exports) | ||
- [Defined entities in a module](#defined-entities-in-a-module) | ||
- [Synthetic module](#synthetic-module) | ||
- [Exports with multiple targets](#exports-with-multiple-targets) | ||
|
||
<!-- /MarkdownTOC --> | ||
|
||
## Qualified Names | ||
|
||
In the following text, **entity** shall denote a module, a method (instance, | ||
static, foreign), type, or a type constructor. In other words, an _entity_ is | ||
anything that can be assigned to a variable. | ||
static, extension, conversion or foreign), type, or a type constructor. | ||
|
||
Both imports and exports require the use of qualified entity names. A qualified | ||
name consists of the library namespace (usually organization under which its | ||
|
@@ -95,6 +99,30 @@ Imports in Enso _may_ introduce ambiguous symbols, which is treated as a | |
compilation error. Ideally, the error should be delayed until one of the | ||
ambiguous symbols is _used_ in Enso code. | ||
|
||
## Imports with multiple targets | ||
|
||
Import of one symbol can resolve to multiple targets in case of extension or | ||
conversion methods. For example, the following import in `Main.enso`: | ||
`A_Module.enso`: | ||
|
||
``` | ||
type My_Type | ||
type Other_Type | ||
My_Type.method = 42 | ||
Other_Type.method = 42 | ||
``` | ||
|
||
`Main.enso`: | ||
|
||
``` | ||
import project.A_Module.method | ||
``` | ||
|
||
imports both `My_Type.method` and `Other_Type.method` methods. | ||
|
||
Note that `import project.A_Module.My_Type.method` would lead to a compilation | ||
error, as it is only possible to import constructors from a type, not methods. | ||
|
||
## Export Syntax | ||
|
||
In order to allow for easy composition and aggregation of code, Enso provides | ||
|
@@ -112,31 +140,19 @@ the name provided after the `as` keyword, if provided). | |
|
||
### Unqualified Exports | ||
|
||
Unqualified exports are broken up into three main categories: | ||
Unlike imports, exports cannot be used with the `all` and `hiding` keywords. So | ||
the only supported syntax is to export a list of names with _restricted | ||
exports_. | ||
Akirathan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
1. **Unrestricted Exports:** These export all symbols from the module or type | ||
into the current scope. They consist of the keyword `from`, followed by a | ||
qualified module name, followed by an optional rename part (using the `as` | ||
keyword), then the keywords `export all`. For example: | ||
``` | ||
from Standard.Base.Data.List as Builtin_List export all | ||
``` | ||
2. **Restricted Exports:** These export a specified set of names, behaving as | ||
though they were redefined in the current scope. They consist of the keyword | ||
`from`, followed by a qualified module or type name (with optional | ||
`as`-rename), then the word `export` followed by a coma-separated list of | ||
names to be exported. For example: | ||
``` | ||
from Standard.Base.Data.List export Cons, Nil, from_vector | ||
``` | ||
3. **Hiding Exports:** These are the inverse of restricted exports, and export | ||
_all_ symbols other than the named ones. They consist of the `from` keyword, | ||
followed by a qualified module or type name (with optional `as`-rename), then | ||
the words `export all hiding`, followed by a coma-separated list of names to | ||
be excluded from the export. For example: | ||
``` | ||
from Standard.Base.Data.List export all hiding from_vector, Nil | ||
``` | ||
**Restricted Exports:** These export a specified set of names, behaving as | ||
though they were redefined in the current scope. They consist of the keyword | ||
`from`, followed by a qualified module or type name (with optional `as`-rename), | ||
then the word `export` followed by a coma-separated list of names to be | ||
Akirathan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exported. For example: | ||
|
||
``` | ||
from Standard.Base.Data.List export Cons, Nil, from_vector | ||
``` | ||
|
||
In essence, an export allows the user to "paste" the contents of the module or | ||
type being exported into the module declaring the export. This means that | ||
|
@@ -146,3 +162,63 @@ exports that create name clashes must be resolved at the _export_ site. | |
|
||
Bindings exported from a module `X` are available in an identical fashion to | ||
bindings that are _defined_ in the module `X`. | ||
|
||
### Implicit exports | ||
|
||
The compiler inserts implicit exports for entities defined in a module and for | ||
submodules of a _synthetic module_. A synthetic module is basically a directory | ||
in the source structure. | ||
|
||
#### Defined entities in a module | ||
|
||
Entities defined in a module are automatically exported from the module. This | ||
means that the following modules are semantically identical: | ||
|
||
``` | ||
type My_Type | ||
method x = x | ||
``` | ||
|
||
``` | ||
export project.Module.My_Type | ||
export project.Module.method | ||
Akirathan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type My_Type | ||
method x = x | ||
``` | ||
|
||
#### Synthetic module | ||
|
||
Consider a project named `Proj` with the following source structure: | ||
|
||
`Proj/src/Synthetic_Mod/Module.enso`: | ||
|
||
``` | ||
type My_Type | ||
``` | ||
|
||
`Proj/src/Main.enso`: | ||
|
||
``` | ||
import project.Synthetic_Mod.Module.My_Type | ||
``` | ||
|
||
We can import submodules of `Synthetic_Mod`, because the compiler automatically | ||
inserts exports for them. Internally, `Synthetic_Mod` is represented as a module | ||
with single export: | ||
|
||
``` | ||
export project.Synthetic_Mod.Module | ||
``` | ||
|
||
## Exports with multiple targets | ||
|
||
Export of a single symbol can be resolved to multiple targets (entities) in case | ||
of extension or conversion methods. Similarly to | ||
[imports with multiple targets](#imports-with-multiple-targets), the following | ||
export in `A_Module.enso`: | ||
|
||
``` | ||
export project.A_Module.export | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably should have been: - export project.A_Module.export
+ export project.A_Module.method |
||
``` | ||
|
||
exports both `My_Type.method` and `Other_Type.method` methods. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is
from ... export
deprecated even when it's not usingall
?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.
They are not deprecated, they are just now suffering from #10399. Until that issue is fixed, rule of a thumb is to just use plain
export ...
.