-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Compile-time error when loading a library with the same name #5715
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
Comments
Johnni mentions that we should be careful about preventing exporting from the same library. cc @johnniwinther. |
I'm deleting the comment #2. That arose from a stale assertion in a co19 test. |
Added Accepted label. |
Added this to the M1 milestone. |
Would that break circular imports? |
We certainly don't wnat that to happen. We'll look into this and see what if anything makes sense. |
Removed this from the M1 milestone. |
I just noticed this part of the specification, and I was actually surprised when I saw it. I saw this error in my code this week as it just got implemented as part of the editor. I understand that we want to follow some dot-naming conventions to avoid these errors (as mentioned in issue #3206), but I was hoping we could avoid having additional naming constraints than we actually need. Consider the following scenario. I depend on 2 libraries created by other people, which have the same library name: project1/a.dart: project2/a.dart: c.dart: There is actually no dependency in my code on the library names (assuming I'm not using mirrors) and no duplicate definitions, but I'll get an error. Note that I can circumvent the error by creating a 'trampoline' library: d.dart: then change c.dart: The fact that I can work around the error makes me wonder whether the error should be there in the first place. I'm sure I'm missing a lot of details about why we have this rule. May I ask, what is the actual motivation for the rule? Is it so that runtime mirrors can uniquely identify a library? If so, maybe we meed to avoid 2 duplicate libraries names in the entire isolate? I personally don't want such error either, and I'm not sure what the right solution is here. Some ideas/proposals: * remove this error altogether?
With the partial information I have, I currently prefer the third option. |
We've eliminate the requirement that library names do not conflict in the draft 0.32 spec. Added Done label. |
Right now, the specification says:
"It is a compile-time error to import two different libraries with the same name."
I'm not sure this fully captures the situations we would like to diagnose.
I think it should be a compile-time error to import a library named L directly or indirectly from a library named L.
Also, it should be a warning if there are two libraries with the same name anywhere.
The text was updated successfully, but these errors were encountered: