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

Failure of exhaustiveness checker when matching on Exception #4555

Open
3 tasks done
JLimperg opened this issue Jun 24, 2024 · 3 comments
Open
3 tasks done

Failure of exhaustiveness checker when matching on Exception #4555

JLimperg opened this issue Jun 24, 2024 · 3 comments
Labels
bug Something isn't working P-medium We may work on this issue if we find the time

Comments

@JLimperg
Copy link
Contributor

JLimperg commented Jun 24, 2024

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

MWE:

import Lean

open Lean

example (e : Exception) : True :=
  match e with
  | .internal .. => sorry
  | .error .. => sorry

-- missing cases:
-- (@Exception.internal _ (KVMap.mk (List.cons (Prod.mk _ (DataValue.ofSyntax _)) _)))
-- (@Exception.internal _ (KVMap.mk (List.cons (Prod.mk _ (DataValue.ofInt (Int.negSucc _))) _)))
-- (@Exception.internal _ (KVMap.mk (List.cons (Prod.mk _ (DataValue.ofInt (Int.ofNat _))) _)))
-- (@Exception.internal _ (KVMap.mk (List.cons (Prod.mk _ (DataValue.ofNat _)) _)))
-- (@Exception.internal _ (KVMap.mk (List.cons (Prod.mk _ (DataValue.ofName _)) _)))
-- (@Exception.internal _ (KVMap.mk (List.cons (Prod.mk _ (DataValue.ofBool true)) _)))
-- (@Exception.internal _ (KVMap.mk (List.cons (Prod.mk _ (DataValue.ofBool false)) _)))
-- (@Exception.internal _ (KVMap.mk (List.cons (Prod.mk _ (DataValue.ofString (String.mk _))) _)))

Versions

"4.10.0-nightly-2024-06-24"

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@JLimperg JLimperg added the bug Something isn't working label Jun 24, 2024
@leodemoura
Copy link
Member

The issue here is that Exception.internal has a default argument.

inductive Exception where
  | error (ref : Syntax) (msg : MessageData)
  | internal (id : InternalExceptionId) (extra : KVMap := {})

Thus, .internal .. is equivalent to .internal _ {}. Possible solutions:

  • A better error message.
  • Modify the meaning of ...

@leodemoura
Copy link
Member

Workaround.

import Lean

open Lean

example (e : Exception) : True :=
  match e with
  | .internal _ _ => sorry
  | .error .. => sorry

@JLimperg
Copy link
Contributor Author

Ah, it's the default argument! I understand .. as "ignore all other arguments", so I would prefer if there was no distinction between arguments with and without a default value.

@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-medium We may work on this issue if we find the time
Projects
None yet
Development

No branches or pull requests

3 participants