Skip to content

Panic: uncaught pattern violation #7643

Closed

Description

@noughtmare

I'm using Agda 2.6.4.3 (which is the latest on brew) and I encountered the uncaught pattern violation panic. I know the code is probably buggy, but I didn't expect a panic.

Here's a small reproducer:

variable A B : Set

data ⊥ : Set where

¬_ : Set → Set
¬ A = A → ⊥

record _×_ (A : Set) (B : Set) : Set where
    constructor _,_
    field
        π₁ : A
        π₂ : B
infixr 20 _×_

data _⊎_ (A : Set) (B : Set) : Set where
    inl : A → A ⊎ B
    inr : B → A ⊎ B

data Dec : Set → Set₁ where
    yes : A → Dec A
    no : ¬ A → Dec A

forget : Dec A → Set
forget {A} _ = A

data _≡_ {A : Set} (x : A) : A → Set where
    refl : x ≡ x

data ⊤ : Set where
    tt : ⊤

data Symbol : Set where
    s : Symbol
-- ...

data String : Set where
    [] : String
    _∷_ : Symbol → String → String

variable c : Symbol
         w : String

_++_ : String → String → String
[] ++ ys = ys
(x ∷ xs) ++ ys = x ∷ (xs ++ ys)

record Σ (A : Set) (B : A → Set) : Set where
    constructor _,_
    field
        π₁ : A
        π₂ : B π₁
infixr 20 _,_

Lang : Set₁
Lang = String → Set

variable V : Set
data Gram V : Set₁ where
    ∅ ε : Gram V
    `_ : Symbol → Gram V
    _·_ : {A : Set} → Dec A → Gram V → Gram V
    _∪_ _▹_ : Gram V → Gram V → Gram V
    var : V → Gram V

variable G G₁ G₂ : Gram V

⟦_⟧ : Gram ⊥ → Lang
⟦ ∅ ⟧ _ = ⊥
⟦ ε ⟧ w = w ≡ []
⟦ A · G ⟧ w = forget A × ⟦ G ⟧ w
⟦ G₁ ∪ G₂ ⟧ w = ⟦ G₁ ⟧ w ⊎ ⟦ G₂ ⟧ w
⟦ G₁ ▹ G₂ ⟧ w = Σ String λ u → Σ String λ v → (w ≡ (u ++ v)) × ⟦ G₁ ⟧ u × ⟦ G₂ ⟧ v
⟦ ` x ⟧ w = w ≡ (x ∷ [])

Activity

  1. noughtmare commented on Dec 6, 2024

    @noughtmare
    CollaboratorAuthor

    Ah, I forgot the type signature of V. If I change the data declaration of Gram to this then it starts giving normal errors again:

    data Gram (V : Set) : Set₁ where
    
  2. szumixie commented on Dec 6, 2024

    @szumixie
    Member

    Reproducible on master, minimized:

    data ⊥ : Set where
    
    data Gram V : Set₁ where
        var : V → Gram V
    
    f : Gram ⊥ → ⊥
    f (var ())
  3. added
    internal-error
    on Dec 6, 2024
  4. added this to the 2.8.0 milestone on Dec 6, 2024
  5. andreasabel commented on Dec 7, 2024

    @andreasabel
    Member

    I have trouble bisecting this because work on #3733 by @Saizan was integrated via a merge commit (621894f) rather than squashed. It contains tons of commits that do not build on GHC 9.0 (even though 2.6.2 supported 9.0) due to a base upper bound on GHC 8.10. However, some commits do not build on GHC 8.10 because that has a too old version of transformers.

    My first run (GHC 9.0.2) gave this bisect result:

    There are only 'skip'ped commits left to test.
    The first bad commit could be any of:
    46691c4
    c99bfd8
    f07d3f4
    39f675b
    a38bb17
    2443403
    408dcf8
    65574a9
    f794e0c
    afa75ee
    fd22b76
    12c3ec2
    89b4ddf
    714398a
    f17c2bb
    0e2634d
    e2167df
    057219a
    f091d33
    62119ab
    be8a0db
    3c4b8bd
    8a934c8
    0fad465
    8c2e712
    43e610e
    99af0d6
    64b6467
    c46d750
    a2766ef
    fe2abed
    9cfa6b8
    b4209b1
    0359421
    a12880b
    2b443eb
    acc125b
    7ce7525
    f6f79d5
    1287f5b
    b6b8370
    077316e
    1642159
    ccb3fec
    ff32e90
    39168f8
    dbb2e7d
    08f219f
    f84b787
    66dd13a
    b0bc150
    33a918a
    3c16549
    470b4ab
    7dae4b5
    5b67673
    5e98fb8
    732e027
    c9ff1cd
    56f2e72
    aa6f51f
    4a849d8
    af9da7c
    d845567
    ed988a3
    145dc62
    6e08bc5
    3fd5d56
    843e863
    171b998
    8e757de
    d2effd4
    e156a85
    8564422
    980cf63
    621894f
    c42760a
    3560209
    ee72211
    c5402b8
    We cannot bisect more!

    This is a ton of small commits developed in a long span from 2024-05-04 to 2021-08-21 (15 months).

  6. andreasabel commented on Dec 7, 2024

    @andreasabel
    Member

    @UlfNorell Not sure if you still hold the belief in merge commits (you were defending this method of merging a PR at least until recently). If yes, you can defend your belief by bisecting this issue.

  7. andreasabel commented on Dec 7, 2024

    @andreasabel
    Member

    Bisecting with GHC 8.10.7 gives this:

    HEAD is now at 4a849d8 Merge branch 'issue3733'
    Result: Failure (bad)
    Stdout:
    Checking Issue7643 (/Users/abel/tmp/agda/Issue7643.agda).
    Panic: uncaught pattern violation
    Verdict: Bad
    There are only 'skip'ped commits left to test.
    The first bad commit could be any of:
    65574a9
    afa75ee
    12c3ec2
    408dcf8
    39f675b
    f17c2bb
    c99bfd8
    e2167df
    057219a
    46691c4
    62119ab
    f07d3f4
    8a934c8
    a38bb17
    0fad465
    2443403
    43e610e
    f794e0c
    c46d750
    fd22b76
    89b4ddf
    a2766ef
    714398a
    b4209b1
    0359421
    0e2634d
    acc125b
    f091d33
    be8a0db
    f6f79d5
    1287f5b
    3c4b8bd
    1642159
    8c2e712
    99af0d6
    ff32e90
    64b6467
    dbb2e7d
    08f219f
    fe2abed
    9cfa6b8
    b0bc150
    3c16549
    a12880b
    2b443eb
    7dae4b5
    5e98fb8
    7ce7525
    732e027
    b6b8370
    077316e
    56f2e72
    af9da7c
    ccb3fec
    39168f8
    ed988a3
    6e08bc5
    f84b787
    3fd5d56
    66dd13a
    171b998
    33a918a
    470b4ab
    d2effd4
    5b67673
    980cf63
    c42760a
    c9ff1cd
    3560209
    aa6f51f
    4a849d8
    We cannot bisect more!

    So, bisect can only blame the merging commit for #3733, which merged a ton of now unbuildable commits.
    This merge commit changed over 4000 lines.

    +4245 -964 lines changed

  8. andreasabel commented on Dec 7, 2024

    @andreasabel
    Member

    Here is a version of the MWE with "standard" names and an option that suppresses the regular error caused by unsolved metas:

    {-# OPTIONS --allow-unsolved-metas #-}
    
    data ⊥ : Set where
    
    data Wrap (A : _) : Set1 where
      wrap : A → Wrap A
    
    test : Wrap ⊥ → ⊥
    test (wrap ())

    The error goes away if one either solves _ (e.g. by Set) or turns Set1 into Set (which I suppose also solves the meta by constraining it fully).

  9. added a commit that references this issue on Jan 2, 2025
    af6ac45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    internal-errorregression in 2.6.3

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions