Skip to content

Commit a272296

Browse files
Fix elab async issue in tactic mode + add 2 new tests
1 parent f7493fc commit a272296

File tree

5 files changed

+86
-1
lines changed

5 files changed

+86
-1
lines changed

REPL/Snapshots.lean

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,12 @@ def create (ctx : ContextInfo) (lctx? : Option LocalContext) (prevEnv? : Option
211211
let s := match prevEnv? with
212212
| none => s
213213
| some env => { s with env }
214+
let coreCtx ← readThe Core.Context
215+
-- Ensure tactic snapshots run synchronously.
216+
let coreCtx := { coreCtx with options := coreCtx.options.insert `Elab.async false }
214217
pure <|
215218
{ coreState := s
216-
coreContext := ← readThe Core.Context
219+
coreContext := coreCtx
217220
metaState := ← getThe Meta.State
218221
metaContext := ← readThe Meta.Context
219222
termState := {}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{"messages":
2+
[{"severity": "error",
3+
"pos": {"line": 1, "column": 0},
4+
"endPos": {"line": 1, "column": 7},
5+
"data":
6+
"(kernel) application type mismatch\n @Eq.ndrec Nat (n✝ + 1) (fun x => x = 0)\n (have this := of_decide_eq_true (id (Eq.refl true));\n of_decide_eq_true (id (Eq.refl true)))\nargument has type\n true = true\nbut function has type\n (fun x => x = 0) (n✝ + 1) → ∀ {b : Nat}, n✝ + 1 = b → (fun x => x = 0) b"}],
7+
"env": 0}
8+
9+
{"sorries":
10+
[{"proofState": 0,
11+
"pos": {"line": 1, "column": 19},
12+
"goal": "⊢ 1 = 0",
13+
"endPos": {"line": 1, "column": 24}}],
14+
"messages":
15+
[{"severity": "warning",
16+
"pos": {"line": 1, "column": 0},
17+
"endPos": {"line": 1, "column": 7},
18+
"data": "declaration uses 'sorry'"}],
19+
"env": 1}
20+
21+
{"proofStatus": "Incomplete: open goals remain",
22+
"proofState": 1,
23+
"goals": ["case zero\n⊢ 0 = 0", "case succ\nn✝ : Nat\n⊢ n✝ + 1 = 0"]}
24+
25+
{"proofStatus": "Incomplete: open goals remain",
26+
"proofState": 2,
27+
"goals": ["case succ\nn✝ : Nat\n⊢ n✝ + 1 = 0"]}
28+
29+
{"proofStatus":
30+
"Error: kernel type check failed: (kernel) application type mismatch\n @Eq.ndrec Nat (n✝ + 1) (fun x => x = 0)\n (have this := of_decide_eq_true (id (Eq.refl true));\n of_decide_eq_true (id (Eq.refl true)))\nargument has type\n true = true\nbut function has type\n (fun x => x = 0) (n✝ + 1) → ∀ {b : Nat}, n✝ + 1 = b → (fun x => x = 0) b",
31+
"proofState": 3,
32+
"goals": []}
33+
34+
{"sorries": [{"proofState": 4, "goal": "n✝ : Nat\n⊢ true = true"}],
35+
"proofStatus": "Incomplete: open goals remain",
36+
"proofState": 5,
37+
"goals": ["case succ\nn✝ : Nat\nthis : true = true\n⊢ n✝ + 1 = 0"]}
38+
39+
{"message":
40+
"Lean error:\nTactic `apply` failed: could not unify the type of `?succ`\n n✝ + 1 = 0\nwith the goal\n true = true\n\nn✝ : Nat\n⊢ true = true"}
41+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{"cmd": "example : 1 = 0 := by\n cases 1\n rfl\n have: true := by\n apply ?succ\n trivial", "setOptions":[[["Elab","async"],true]]}
2+
3+
{"cmd": "example : 1 = 0 := sorry", "setOptions":[[["Elab","async"],true]]}
4+
5+
{"tactic": "cases 1", "proofState": 0}
6+
7+
{"tactic": "rfl", "proofState": 1}
8+
9+
{"tactic": "have: true := by\n apply ?succ\n trivial", "proofState": 2}
10+
11+
{"tactic": "have: true := sorry", "proofState": 2}
12+
13+
{"tactic": "apply ?succ", "proofState": 4}
14+

test/set_option.expected.out

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{"messages":
2+
[{"severity": "info",
3+
"pos": {"line": 8, "column": 0},
4+
"endPos": {"line": 8, "column": 8},
5+
"data": "Elab.async = false"}],
6+
"env": 0}
7+
8+
{"messages":
9+
[{"severity": "info",
10+
"pos": {"line": 10, "column": 0},
11+
"endPos": {"line": 10, "column": 8},
12+
"data": "Elab.async = true"}],
13+
"env": 1}
14+
15+
{"messages":
16+
[{"severity": "info",
17+
"pos": {"line": 8, "column": 0},
18+
"endPos": {"line": 8, "column": 8},
19+
"data": "Elab.async = true"}],
20+
"env": 2}
21+

test/set_option.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{"cmd": "import Lean\nopen Lean Elab Command\n\nelab \"#show_pp\" : command => do\n let o ← getOptions\n logInfo m!\"Elab.async = {Elab.async.get o}\"\n\n#show_pp"}
2+
3+
{"cmd": "import Lean\nopen Lean Elab Command\n\nset_option Elab.async true\n\nelab \"#show_pp\" : command => do\n let o ← getOptions\n logInfo m!\"Elab.async = {Elab.async.get o}\"\n\n#show_pp"}
4+
5+
{"cmd": "import Lean\nopen Lean Elab Command\n\nelab \"#show_pp\" : command => do\n let o ← getOptions\n logInfo m!\"Elab.async = {Elab.async.get o}\"\n\n#show_pp", "setOptions":[[["Elab","async"],true]]}
6+

0 commit comments

Comments
 (0)