From 1d66ff82318a8597f5203e8745d3e77b7f975f70 Mon Sep 17 00:00:00 2001 From: Kyle Miller Date: Thu, 17 Oct 2024 18:44:52 -0700 Subject: [PATCH] fix: app unexpander for `sorryAx` (#5759) Fixes a long-standing bug in the the `sorryAx` app unexpander that prevented it from applying. Now `sorry` pretty prints as `sorry`. --- src/Init/NotationExtra.lean | 6 ++--- tests/lean/1074b.lean.expected.out | 2 +- tests/lean/1301.lean.expected.out | 2 +- tests/lean/255.lean.expected.out | 4 +-- tests/lean/StxQuot.lean.expected.out | 2 +- .../lean/binrelTypeMismatch.lean.expected.out | 4 +-- tests/lean/defInst.lean.expected.out | 2 +- tests/lean/macroSwizzle.lean.expected.out | 2 +- .../lean/nameArgErrorIssue.lean.expected.out | 2 +- tests/lean/namedHoles.lean.expected.out | 4 +-- tests/lean/noTabs.lean.expected.out | 2 +- tests/lean/run/1163.lean | 2 +- tests/lean/run/1910.lean | 6 ++--- tests/lean/run/2283.lean | 6 ++--- tests/lean/run/3554.lean | 4 +-- tests/lean/run/3943.lean | 8 +++--- tests/lean/run/4365.lean | 2 +- tests/lean/run/4670.lean | 4 +-- tests/lean/run/4920.lean | 2 +- tests/lean/run/CoeNew.lean | 4 +-- tests/lean/run/autoLift.lean | 2 +- tests/lean/run/sorry.lean | 26 +++++++++++++++++++ 22 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 tests/lean/run/sorry.lean diff --git a/src/Init/NotationExtra.lean b/src/Init/NotationExtra.lean index b96ec37d9d..1542241703 100644 --- a/src/Init/NotationExtra.lean +++ b/src/Init/NotationExtra.lean @@ -168,9 +168,9 @@ end Lean | _ => throw () @[app_unexpander sorryAx] def unexpandSorryAx : Lean.PrettyPrinter.Unexpander - | `($(_) _) => `(sorry) - | `($(_) _ _) => `(sorry) - | _ => throw () + | `($(_) $_) => `(sorry) + | `($(_) $_ $_) => `(sorry) + | _ => throw () @[app_unexpander Eq.ndrec] def unexpandEqNDRec : Lean.PrettyPrinter.Unexpander | `($(_) $m $h) => `($h ▸ $m) diff --git a/tests/lean/1074b.lean.expected.out b/tests/lean/1074b.lean.expected.out index 538f7ad485..8cc7a50dba 100644 --- a/tests/lean/1074b.lean.expected.out +++ b/tests/lean/1074b.lean.expected.out @@ -2,4 +2,4 @@ 1074b.lean:11:43-11:53: error: tactic 'assumption' failed a n z✝ : Term a✝ : Brx z✝ -⊢ Brx (sorryAx Term true) +⊢ Brx sorry diff --git a/tests/lean/1301.lean.expected.out b/tests/lean/1301.lean.expected.out index c760eef6e5..ca1e4d01ae 100644 --- a/tests/lean/1301.lean.expected.out +++ b/tests/lean/1301.lean.expected.out @@ -6,4 +6,4 @@ a' : True ∧ True 1301.lean:9:25-9:29: error: elaboration function for 'termTerm' has not been implemented term def b : Nat → Nat := -sorryAx (Nat → Nat) true +sorry diff --git a/tests/lean/255.lean.expected.out b/tests/lean/255.lean.expected.out index b163a7dcb8..d9978a70dd 100644 --- a/tests/lean/255.lean.expected.out +++ b/tests/lean/255.lean.expected.out @@ -1,6 +1,6 @@ A : α id x✝ : α 255.lean:16:7-16:8: error: unknown constant 'x✝' -id (sorryAx ?m true) : ?m +id sorry : ?m 255.lean:20:9-20:10: error: unknown constant 'x✝' -id (sorryAx ?m true) : ?m +id sorry : ?m diff --git a/tests/lean/StxQuot.lean.expected.out b/tests/lean/StxQuot.lean.expected.out index 39f024c723..1256d67be4 100644 --- a/tests/lean/StxQuot.lean.expected.out +++ b/tests/lean/StxQuot.lean.expected.out @@ -45,7 +45,7 @@ StxQuot.lean:83:7-83:19: error: unknown identifier 'sufficesDecl' "#[(num \"1\"), [(num \"2\") (num \"3\")], (num \"4\")]" "#[(num \"2\")]" StxQuot.lean:97:39-97:44: error: unexpected antiquotation splice -fun x => sorryAx (?m x) true : (x : ?m) → ?m x +fun x => sorry : (x : ?m) → ?m x "#[(some 1), (some 2)]" StxQuot.lean:104:13-104:14: error: unknown identifier 'x' at quotation precheck; you can use `set_option quotPrecheck false` to disable this check. "`id._@.UnhygienicMain._hyg.1" diff --git a/tests/lean/binrelTypeMismatch.lean.expected.out b/tests/lean/binrelTypeMismatch.lean.expected.out index 7a8b646d19..55b2934ee0 100644 --- a/tests/lean/binrelTypeMismatch.lean.expected.out +++ b/tests/lean/binrelTypeMismatch.lean.expected.out @@ -10,11 +10,11 @@ has type Prop : Type but is expected to have type Bool : Type -Prop → sorryAx (Sort u_1) true : Sort (imax 1 u_1) +Prop → sorry : Sort (imax 1 u_1) binrelTypeMismatch.lean:20:27-20:28: error: type mismatch p has type Prop : Type but is expected to have type Bool : Type -Prop → sorryAx (Sort u_1) true : Sort (imax 1 u_1) +Prop → sorry : Sort (imax 1 u_1) diff --git a/tests/lean/defInst.lean.expected.out b/tests/lean/defInst.lean.expected.out index cf1ab9fccc..7655b755a4 100644 --- a/tests/lean/defInst.lean.expected.out +++ b/tests/lean/defInst.lean.expected.out @@ -2,7 +2,7 @@ defInst.lean:8:26-8:32: error: failed to synthesize BEq Foo Additional diagnostic information may be available using the `set_option diagnostics true` command. -fun x y => sorryAx (?m x y) true : (x y : Foo) → ?m x y +fun x y => sorry : (x y : Foo) → ?m x y [4, 5, 6] fun x y => x == y : Foo → Foo → Bool [("hello", "hello")] diff --git a/tests/lean/macroSwizzle.lean.expected.out b/tests/lean/macroSwizzle.lean.expected.out index 7900d1a430..cb31d75145 100644 --- a/tests/lean/macroSwizzle.lean.expected.out +++ b/tests/lean/macroSwizzle.lean.expected.out @@ -9,4 +9,4 @@ has type String : Type but is expected to have type Nat : Type -(sorryAx Nat true).succ : Nat +sorry.succ : Nat diff --git a/tests/lean/nameArgErrorIssue.lean.expected.out b/tests/lean/nameArgErrorIssue.lean.expected.out index 80768a7573..dc686d546a 100644 --- a/tests/lean/nameArgErrorIssue.lean.expected.out +++ b/tests/lean/nameArgErrorIssue.lean.expected.out @@ -7,7 +7,7 @@ has type String : Type but is expected to have type Nat : Type -bla (sorryAx Nat true) 5 : Nat +bla sorry 5 : Nat nameArgErrorIssue.lean:6:20-6:24: error: application type mismatch bla "hi" argument diff --git a/tests/lean/namedHoles.lean.expected.out b/tests/lean/namedHoles.lean.expected.out index 85577d3d73..63babc018d 100644 --- a/tests/lean/namedHoles.lean.expected.out +++ b/tests/lean/namedHoles.lean.expected.out @@ -6,13 +6,13 @@ has type Nat : Type but is expected to have type Bool : Type -f ?x (sorryAx Bool true) : Nat +f ?x sorry : Nat g ?x ?x : Nat 20 foo (fun x => ?hole) ?hole : Nat bla ?hole fun x => ?hole : Nat namedHoles.lean:35:38-35:43: error: synthetic hole has already been defined with an incompatible local context -boo (fun x => ?hole) fun y => sorryAx Nat true : Nat +boo (fun x => ?hole) fun y => sorry : Nat 11 12 namedHoles.lean:58:26-58:31: error: synthetic hole has already been defined and assigned to value incompatible with the current context diff --git a/tests/lean/noTabs.lean.expected.out b/tests/lean/noTabs.lean.expected.out index 9e301c5081..5262009f31 100644 --- a/tests/lean/noTabs.lean.expected.out +++ b/tests/lean/noTabs.lean.expected.out @@ -1,3 +1,3 @@ noTabs.lean:3:0: error: tabs are not allowed; please configure your editor to expand them let a := 1; -sorryAx ?m true : ?m +sorry : ?m diff --git a/tests/lean/run/1163.lean b/tests/lean/run/1163.lean index 928dd171bf..7615d703a2 100644 --- a/tests/lean/run/1163.lean +++ b/tests/lean/run/1163.lean @@ -1,7 +1,7 @@ import Lean open Lean Elab Tactic -macro "obviously1" : tactic => `(tactic| exact sorryAx _) +macro "obviously1" : tactic => `(tactic| exact sorryAx _ false) theorem result1 : False := by obviously1 diff --git a/tests/lean/run/1910.lean b/tests/lean/run/1910.lean index dfc13d6ec9..0b1b833e0a 100644 --- a/tests/lean/run/1910.lean +++ b/tests/lean/run/1910.lean @@ -56,7 +56,7 @@ error: invalid field notation, function 'Nat.foo' has argument with the expected Nat but it cannot be used --- -info: fun n => sorryAx (?_ n) true : (n : Nat) → ?_ n +info: fun n => sorry : (n : Nat) → ?_ n -/ #guard_msgs in #check fun (n : Nat) => n.foo @@ -81,7 +81,7 @@ def Bar.bar : Bar true := {} /-- error: invalid field notation, function 'Bar.bar' does not have argument with type (Bar ...) that can be used, it must be explicit or implicit with a unique name --- -info: fun f => sorryAx (?_ f) true : (f : Bar false) → ?_ f +info: fun f => sorry : (f : Bar false) → ?_ f -/ #guard_msgs in #check fun (f : Bar false) => f.bar false @@ -90,6 +90,6 @@ info: fun f => sorryAx (?_ f) true : (f : Bar false) → ?_ f /-- error: invalid field notation, function 'Bar.bar' does not have argument with type (Bar ...) that can be used, it must be explicit or implicit with a unique name --- -info: fun f => sorryAx (?_ f) true : (f : Bar false) → ?_ f +info: fun f => sorry : (f : Bar false) → ?_ f -/ #guard_msgs in #check fun (f : Bar false) => f.bar true false diff --git a/tests/lean/run/2283.lean b/tests/lean/run/2283.lean index 9a9b7e4ba8..6b31a0e3e5 100644 --- a/tests/lean/run/2283.lean +++ b/tests/lean/run/2283.lean @@ -33,11 +33,11 @@ instance hasLimitsOfSize : HasLimitsOfSize.{v} (Type max v u) := sorry set_option pp.mvars false /-- error: type mismatch - limit.π (sorryAx (Functor' ?_ ?_)) (sorryAx ?_) + limit.π sorry sorry has type - sorryAx (Sort _) : Sort _ + sorry : Sort _ but is expected to have type - limit f → sorryAx (Sort _) : Sort (imax (max (u + 1) (v + 1)) _) + limit f → sorry : Sort (imax (max (u + 1) (v + 1)) _) -/ #guard_msgs in theorem pi_lift_π_apply {C : Type v} [Category.{v} C] (f : Functor' C (Type max v u)) : diff --git a/tests/lean/run/3554.lean b/tests/lean/run/3554.lean index 9065f3987b..fe545a79ec 100644 --- a/tests/lean/run/3554.lean +++ b/tests/lean/run/3554.lean @@ -15,7 +15,7 @@ theorem bar : True := by /-- info: theorem bar : True := -sorryAx True true +sorry -/ #guard_msgs in #print bar @@ -31,7 +31,7 @@ theorem bar2 : True := by /-- info: theorem bar2 : True := -sorryAx True true +sorry -/ #guard_msgs in #print bar2 diff --git a/tests/lean/run/3943.lean b/tests/lean/run/3943.lean index 3d8fba43d1..2f7059709e 100644 --- a/tests/lean/run/3943.lean +++ b/tests/lean/run/3943.lean @@ -8,9 +8,9 @@ example (f : Nat → Nat) : f x = 0 → f x + 1 = y := by guard_target =ₛ f x = 0 → 1 = y sorry -example (f : Nat → Nat) : let _ : f x = 0 := sorry; f x + 1 = y := by +example (f : Nat → Nat) : let _ : f x = 0 := sorryAx _ false; f x + 1 = y := by simp (config := { contextual := true, zeta := false }) - guard_target =ₛ let _ : f x = 0 := sorry; 1 = y + guard_target =ₛ let _ : f x = 0 := sorryAx _ false; 1 = y sorry def overlap : Nat → Nat @@ -45,7 +45,7 @@ example : (if p x then g x else g x + 1) + g x = y := by guard_target =ₛ (if p x then x else g x + 1) + g x = y sorry -example : (let _ : p x := sorry; g x + 1 = y) ↔ g x = y := by +example : (let _ : p x := sorryAx _ false; g x + 1 = y) ↔ g x = y := by simp (config := { zeta := false }) (discharger := assumption) - guard_target =ₛ (let _ : p x := sorry; x + 1 = y) ↔ g x = y + guard_target =ₛ (let _ : p x := sorryAx _ false; x + 1 = y) ↔ g x = y sorry diff --git a/tests/lean/run/4365.lean b/tests/lean/run/4365.lean index cde7a72745..bc30899d06 100644 --- a/tests/lean/run/4365.lean +++ b/tests/lean/run/4365.lean @@ -19,7 +19,7 @@ def f (α : Sort u) : α := error: numerals are data in Lean, but the expected type is universe polymorphic and may be a proposition α : Sort u --- -info: fun {α} => id (id (sorryAx α true)) : {α : Sort u} → α +info: fun {α} => id (id sorry) : {α : Sort u} → α -/ #guard_msgs in #check fun {α : Sort u} => id (α := α) (id 0) diff --git a/tests/lean/run/4670.lean b/tests/lean/run/4670.lean index cf16afd512..bedb293f55 100644 --- a/tests/lean/run/4670.lean +++ b/tests/lean/run/4670.lean @@ -20,7 +20,7 @@ has type but is expected to have type Foo : Type --- -info: (sorryAx Foo true).out : Nat +info: sorry.out : Nat -/ #guard_msgs in #check Foo.out true @@ -38,7 +38,7 @@ has type but is expected to have type Foo : Type --- -info: (sorryAx Foo true).out' : Nat +info: sorry.out' : Nat -/ #guard_msgs in #check Foo.out' true diff --git a/tests/lean/run/4920.lean b/tests/lean/run/4920.lean index c1f2676667..a6faee7512 100644 --- a/tests/lean/run/4920.lean +++ b/tests/lean/run/4920.lean @@ -34,7 +34,7 @@ xm : List (Vect m A) h0 : xm.length = as.length ih : i < (List.zipWith cons as xm).length jh : j < m -⊢ ?_ (sorryAx ?_ true) j +⊢ ?_ sorry j -/ #guard_msgs in theorem Vect.aux diff --git a/tests/lean/run/CoeNew.lean b/tests/lean/run/CoeNew.lean index a4a7f00325..79929a1233 100644 --- a/tests/lean/run/CoeNew.lean +++ b/tests/lean/run/CoeNew.lean @@ -19,8 +19,8 @@ instance constantFunctionCoe {α β : Type} : CoeFun (ConstantFunction α β) (f set_option pp.explicit true -#synth CoeT { x : Nat // x > 0 } ⟨1, sorryAx _⟩ Nat -#synth CoeT { x : Nat // x > 0 } ⟨1, sorryAx _⟩ Bool +#synth CoeT { x : Nat // x > 0 } ⟨1, sorryAx _ false⟩ Nat +#synth CoeT { x : Nat // x > 0 } ⟨1, sorryAx _ false⟩ Bool #synth CoeT Nat 0 (Option Nat) #synth CoeT Bool true (Option Nat) #synth CoeT Prop (0 = 1) Bool diff --git a/tests/lean/run/autoLift.lean b/tests/lean/run/autoLift.lean index 3c053a65be..649378804b 100644 --- a/tests/lean/run/autoLift.lean +++ b/tests/lean/run/autoLift.lean @@ -27,7 +27,7 @@ but is expected to have type M ?_ : Type --- info: id do - let a ← sorryAx (M Nat) true + let a ← sorry g a : M Unit -/ #guard_msgs in diff --git a/tests/lean/run/sorry.lean b/tests/lean/run/sorry.lean new file mode 100644 index 0000000000..7940d9e018 --- /dev/null +++ b/tests/lean/run/sorry.lean @@ -0,0 +1,26 @@ +/-! +# Tests of the `sorry` term elaborator +-/ + +/-! +Basic usage. +-/ + +/-- warning: declaration uses 'sorry' -/ +#guard_msgs in example : False := sorry + +/-- warning: declaration uses 'sorry' -/ +#guard_msgs in example : False := by sorry + +/-! +Pretty printing +-/ + +/-- info: sorry : Nat -/ +#guard_msgs in #check (sorry : Nat) + +/-- info: fun x => sorry : Nat → Nat -/ +#guard_msgs in #check fun x : Nat => (sorry : Nat) + +/-- info: fun x => sorry (x + 1) : Nat → Nat -/ +#guard_msgs in #check fun x : Nat => (sorry : Nat → Nat) (x + 1)