Repository navigation
Conversation
aae22b6 to
c3fa46c
Compare
| is to define the DAG of dependencies so that we can understand what is blocking the high-priority | ||
| items. | ||
|
|
||
| | ID | Name | Description | Dependencies | Status | PRs | |
There was a problem hiding this comment.
My MD formatted did this, if it does not conflict with others, let's keep it
Though it is annoying that it changed whole table
| With `--debug`, debug symbols are numbered in the order in which analysis reaches the calls, so a reordered program can | ||
| get a different debug CMR, as moving a function already could on master. |
There was a problem hiding this comment.
This important point, about which I would like to hear your opinion
There was a problem hiding this comment.
I'm tempted to drop this sentence, and separately we should work on removing --debug in favor or something less invasive.
But I guess that's not on the critical path, and --debug is useful for now, so we'll probably keep it for a while. And in this case, the existing text sounds good to me.
There was a problem hiding this comment.
we should work on removing --debug in favor or something less invasive.
I can create a roadmap item for that
| Every module owns a directory for the files of its child modules: | ||
|
|
||
| - the crate root file `main.simf` owns the directory it is in; | ||
| - the module file `D/x.simf` owns `D/x/`; |
There was a problem hiding this comment.
In c3fa46c:
Feel free to override me, but I have a mild preference for D/x/mod.simf rather than D/x.simf, because it makes it easier to tab-complete in the terminal if we don't have a x/ directory beside an x.simf file.
There was a problem hiding this comment.
Below you mention this, say it's not allowed "for the time being". I think we should pick one and use that exclusively so we don't have style wars in every project.
There was a problem hiding this comment.
I think we should pick one and use that exclusively so we don't have style wars in every project.
Yeah, I had quite a dilemma regarding that
I like both variants in particular cases
I like x.simf in case when it does not have children, and I like D/x/mod.simf when it does have children mods
There was a problem hiding this comment.
After talk with @KyrylR I think we should just support both.
It feels a bit redundant, but unless we want to say "every single module is D/mod.simf even if it has no children", there will always be two possibilities for the no-children case. So we might as well have two possibilities for all cases.
There was a problem hiding this comment.
In 8931a27:
Updated the File layout section
And added these 2 sentences in the deps section:
Inside a dependency, each file is a module, and
use alias::dir::file::itemloadsdir/file.simf.
So, dependencies keep this file-based form.use alias::dir::file::itemloads onlydir/file.simf.
Other form is responsibility of MOD-2 as well.
|
|
||
| The crate root in MOD-1 is defined by passing the file that is passed to `simc` for the compilation. `simc foo.simf` | ||
| makes `foo.simf` the root of the crate, whatever it's named. | ||
| In other words, the directory of the crate root file plays the role of that project root. |
There was a problem hiding this comment.
In c3fa46c:
In still other words, simc is equivalent to simc --project-root ./main.simf?
There was a problem hiding this comment.
Not quite, but yes
--project-root takes a directory, so the equivalent is simc main.simf --project-root .
| For example, `use math::arith::func;` (`func()` is called within the code), with `--dep math=libs/math` flag loads | ||
| `libs/math/arith.simf`. | ||
|
|
||
| `self` and `super` are reserved keywords. There are no glob imports and no qualified paths in expressions. |
There was a problem hiding this comment.
In c3fa46c:
nit: should also say here that crate is reserved.
|
|
||
| #### Visibility | ||
|
|
||
| Items and modules are private unless marked `pub`. |
There was a problem hiding this comment.
In c3fa46c:
Do we want to add pub(super) and pub(crate) here? Or punt on this for now?
There was a problem hiding this comment.
I would defer it to MOD-2 as, in a way, it is more relevant for it and I believe the time gap between MOD-1 and MOD-2 won't be too big
|
|
||
| Note regarding `unit_N`: with `--dep`, each dependency file is wrapped as `mod unit_N { ... }` at the top level, where N | ||
| is the file's source id. | ||
| It is a responsibility of MOD-2 to get rid of `unit_N`. |
There was a problem hiding this comment.
In c3fa46c:
Yeah, I agree with this. I think we can do this in a fairly simple way but it'd still be too much scope for MOD-1.
There was a problem hiding this comment.
Can we replace unit_N with something like #unit_N though so that users can't directly refer to the module name or cause collisions with it?
There was a problem hiding this comment.
Similar to this one: #458 (comment)
I would vote not to do it. IMO it is better to wait for MOD-2 and accept it as is as part of a "transition period"
There was a problem hiding this comment.
About #unit_N, I don't think it helps. After flattening, the name is substituted into the use statements, so users could write the same thing with #. And if we didn't allow that, we would just break flattening
|
nit: I agree that a |
| #### Diagnostics | ||
|
|
||
| All of the above are collected without stopping at the first one. | ||
| A module whose file fails to load stays in the tree without items, so paths into it are not reported again. | ||
|
|
||
| Each import cycle is reported once, as one strongly connected component of the imports that stayed unresolved. | ||
| An import that could only import itself, such as `use crate::typo;` at the crate root, is reported as not found. | ||
|
|
||
| Analysis goes on after a failed import or a broken item, and reports the errors of the items that do not depend on them. |
There was a problem hiding this comment.
In c3fa46c:
Let's model a tricky case:
mod a {
pub mod foo {}
pub fn foo() {}
pub type foo = u32;
}
fn foo() {}
use crate::a::foo;
fn main() {}Master accepts this, because resolve_processing_use_items_error returns Ok as soon as one namespace resolves and drops the other errors. So the RedefinedItem for fn foo is lost, and the local fn foo silently wins. Under this doc's rule (a local item never hides an import, E0255) it should be rejected, which I think is right. But then "same on master: yes" is not always right
There was a problem hiding this comment.
Also, master currently reports only the first import error in the AST phase and then stops. So, either we mention that this will be handled in the DIAG series, or, if you keep it here, you can reuse the code from #451
There was a problem hiding this comment.
Everything related to the diagnostics, should be handled in DIAG part
|
Despite that, LGTM! |
|
In 8931a27: Updated list of reserved keywords and clarified the issue with |
|
A lot of the wording here is kind awkard and confusing. I might do a PR to fix up some of it.
Horray! Although It might be nice to be able to specify a crate-wide prelude, but that's something we can always add later.
How do you refer to things that need a qualified path then? Do we still want to support traits/methods at some point?
I've mentioned this before but we should really avoid Rust's mistake here and have two seperate levels of I'll call them This also gives you nominal typing. For instance if you have something like: Then
Do we actually want to have separate namespaces for modules, types and functions? |
This PR proposes a draft for the MOD-1 point from the roadmap
A lot of decisions were influenced by:
pub,use) and the merged module work Implement module system and program flattening #337, Add module parser #338, Adaptresolution.rsto resolveusestatements and add module errors #339, Add a new strategy for import resolution and rename variables #343, Shift Module Resolution to AST and Introduce Scope Analysis #345, ast: make each use declaration atomic #416 (for compatibility)UseDeclblocks after brokenUseItems#451, Initial top-level roadmap design #456 (comment)