-
Notifications
You must be signed in to change notification settings - Fork 365
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
Check module equality before issuing "Ambiguous name" error #6035
Comments
This may be convenient in the short term but don't you run the risk of building a massive scope |
Relevant: #4331 .. by which I mean that in a structured signature setup, it'd be possible to cheaply implement this, I think? |
Me too. Just ran into the situation of the OP. Very annoying to see an error like:
(This is the error triggered by the OP.)
Ok, there are different paths ending in the same target, but why should this be an error? @gallais argues that it might be a useful information that the module setup has redundancies, but it would suffice to print a warning instead. |
Do you think we could improve this situation slightly by adding the |
Ah, yes, I just also thought we could always directly expand the "hint" given at the end of the error. This information is available where we raise the error, yet we throw it away instead of passing it to the error message. |
Investigating the problem, I found that the two names rendered in the error message have different module Issue6035 where
module M0 (A0 : Set) where
A : Set
A = A0
module M1 (A1 : Set) where
open module M01 = M0 A1 public
module M2 (A2 : Set) where
open module M02 = M0 A2 public
module M3 (A3 : Set) where
open module M1' = M1 A3
open module M2' = M2 A3
B = A With the intermediate names, the error also becomes more plausible:
Since Agda's treatment of module is nominal rather than structural, there isn't much to do here except for making the error a bit clearer --- unless we redesign and reimplement the handling of module applications. |
Also move explainWhyInScope to TypeChecking.Errors
Also move explainWhyInScope to TypeChecking.Errors
I implemented this in: |
Should this be done also for agda/src/full/Agda/TypeChecking/Errors.hs Lines 815 to 827 in bf1a531
|
When I use a defined name
A
that corresponds to multiple definitions, Agda issues an "Ambiguous name" error. However, if the definitions are actually the same piece of code but accessed through differentopen
oropen import
statements and the module ofA
is moreover instantiated each time with the same arguments, then there is no ambiguity andA
should simply be used.Either of the following solutions could work:
Consider the following small example:
In
Fine
, there is no issue, but inBad
, ambiguity is reported forA
. If I replaceA
with an underscore, the file typechecks, showing that bothA
s (the domain ofthence
and the codomain ofthither
) really coincide.As a real life example, in my draft pull request about (relative) adjunctions, the modules
LeftRelativeRightAdhoc
andLeftAdhocRightRelative
both openAdhoc
. The moduleBirelative
opens bothLeftRelativeRightAdhoc
andLeftAdhocRightRelative
, which would lead to consistent openings ofAdhoc
. However, I had to makeLeftRelativeRightAdhoc
andLeftAdhocRightRelative
openAdhoc
non-publicly to avoid ambiguity errors inBirelative
. This is already less than ideal.But I inferred that under the current circumstances,
open ... public
andopen import ... public
are in general an annoying thing to do, so I hadBirelative
export none of the aforementioned modules. Then inNaturalBijection
I had to open all four (actually their non-relative counterparts) where I would just have wanted to writeopen Plain F G public
and have that module open the other three. This means that as a library developer, I have little control over the interface of my modules, which makes it hard to make edits with good backwards compatibility.The text was updated successfully, but these errors were encountered: