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

Internal error with postfix projection #5657

Closed
barrettj12 opened this issue Nov 18, 2021 · 2 comments · Fixed by #5658
Closed

Internal error with postfix projection #5657

barrettj12 opened this issue Nov 18, 2021 · 2 comments · Fixed by #5658
Assignees
Labels
internal-error Concerning internal errors of Agda postfix-projections Issue with projections in postfix form projections Issues relating to the treatment of projections regression in 2.6.2 Regression that first appeared in Agda 2.6.2
Milestone

Comments

@barrettj12
Copy link

I ran the code

open import Relation.Binary.PropositionalEquality using (_≡_)

record Magma : Set₁ where
  field
    A : Set
    _+_ : A  A  A

record CommMagmaFam (I : Set) : Set₁ where
  field
    M : I  Magma
    comm : (i : I)  let open Magma (M i) in
      (a b : M i .A) 
      a + b ≡ b + a

and Agda told me

An internal error has occurred. Please report this as a bug.
Location of the error: __IMPOSSIBLE__, called at src/full\Agda\TypeChecking\Rules\Application.hs:968:23 in Agda-2.6.3-8qnHSysNZe1HBYMluPboCb:Agda.TypeChecking.Rules.Application

I am running 6cb77e1, using VSCode's agda-mode on Windows 10.

@andreasabel andreasabel added internal-error Concerning internal errors of Agda regression in 2.6.2 Regression that first appeared in Agda 2.6.2 labels Nov 18, 2021
@andreasabel
Copy link
Member

andreasabel commented Nov 18, 2021

Here is a version without the standard-library:

open import Agda.Builtin.Equality using (_≡_)

record Magma : Set₁ where
  field
    A : Set
    _+_ : A  A  A

record CommMagmaFam (I : Set) : Set₁ where
  field
    M : I  Magma
    comm : (i : I)  let open Magma (M i) in
      (a b : M i .A) 
      a + b ≡ b + a

The error given by Agda 2.5.2 - 2.6.1 is:

Set should be a function type, but it isn't
when checking that (M i) is a valid argument to a function of type Set

This is the correct error.
The crash happens starting in 2.6.2.

pr <- fromMaybe __IMPOSSIBLE__ <$> isProjection x

Seems I introduced this regression in 535da23 when fixing #3289.

@andreasabel andreasabel added this to the 2.6.3 milestone Nov 18, 2021
@andreasabel andreasabel self-assigned this Nov 18, 2021
@andreasabel andreasabel changed the title Internal error Internal error with postfix projection Nov 18, 2021
@andreasabel
Copy link
Member

andreasabel commented Nov 19, 2021

This seems to be the MWE:

record R : Set₁ where
  field A : Set

postulate r : R
open R r

fail : Set
fail = r .A

The scope checker recognizes .A as projection, but then isProjection fails because the open statement brought A : Set into scope, which is clearly not a projection.
Seems like the solution is simply to not throw __IMPOSSIBLE__ at loc.cit., since it is possible if the user made a mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal-error Concerning internal errors of Agda postfix-projections Issue with projections in postfix form projections Issues relating to the treatment of projections regression in 2.6.2 Regression that first appeared in Agda 2.6.2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants