Skip to content
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

Constructor instances do not work outside parameterised modules #5583

Closed
omelkonian opened this issue Oct 5, 2021 · 5 comments · Fixed by #5685
Closed

Constructor instances do not work outside parameterised modules #5583

omelkonian opened this issue Oct 5, 2021 · 5 comments · Fixed by #5685
Labels
import Issues to do with importing modules instance Instance resolution modules Issues relating to the module system type: bug Issues and pull requests about actual bugs
Milestone

Comments

@omelkonian
Copy link
Contributor

omelkonian commented Oct 5, 2021

Let's assume two files with the following definitions:

open import Agda.Builtin.Unit
module File1 (_ : ⊤) where

it :  {A : Set}  ⦃ A ⦄  A
it ⦃ x ⦄ = x

data X : Set where
  instance x : X

_ : X
_ = it

--------------------------------------------

open import Agda.Builtin.Unit
module File2 where

open import File1 tt

_ : X
_ = it

The instance is not available in File2, producing the following error:

No instance of type Y was found in scope.
when checking that the expression it has type Y

NB: If I remove the dummy parameter _ : ⊤ it works, and it was working before v2.6.2.

@omelkonian
Copy link
Contributor Author

Also, the issue does not appear when everything is in one file:

module M₁ (_ : ⊤) where

  data X : Set where
    instance x : X

  _ : X
  _ = it

module M₂ where

  open M₁ tt

  _ : X
  _ = it

@gallais
Copy link
Member

gallais commented Oct 5, 2021

import File1
open File1 tt

works but not open import File1 tt 👀

@omelkonian
Copy link
Contributor Author

Then probably related to #4166.

@jespercockx
Copy link
Member

Isn't the problem that instance search simply does not consider instances that have explicit arguments? Normally there's a warning for that but in this case it (intentionally or unintentionally) does not fire because the argument is a module parameter.

@jespercockx
Copy link
Member

Nevermind, I see the module is actually applied to tt in your example so it should definitely work.

@jespercockx jespercockx added import Issues to do with importing modules instance Instance resolution modules Issues relating to the module system type: bug Issues and pull requests about actual bugs labels Oct 5, 2021
@jespercockx jespercockx added this to the 2.6.3 milestone Oct 5, 2021
UlfNorell added a commit that referenced this issue Dec 6, 2021
UlfNorell added a commit that referenced this issue Dec 6, 2021
@andreasabel andreasabel mentioned this issue Mar 14, 2022
41 tasks
@andreasabel andreasabel modified the milestones: 2.6.3, 2.6.2.2 Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
import Issues to do with importing modules instance Instance resolution modules Issues relating to the module system type: bug Issues and pull requests about actual bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants