Commit 192e182
fix: fresh result type in
The pure continuation in `ControlLifter.lift` now uses a fresh result type
`?α` instead of `l.origCont.resultType`, mirroring the legacy elaborator's
`DoResultPR` pattern. This allows monad resolution to succeed independently
of the expected result type. For example, `evalConstCheck Nat ``Nat name`
in a `CoreM (Option Nat)` try/catch context: with `Option Nat` as expected
type, Lean cannot decompose `?m Nat =?= CoreM (Option Nat)`, leaving `?m`
stuck. With a fresh `?α`, Lean decomposes `?m Nat =?= CoreM ?α`
successfully. The coercion from `?α` to the original result type is
inserted by `mkPure` via `ensureHasType`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>ControlLifter.lift for monad resolution1 parent 1d1c5c6 commit 192e182
File tree
2 files changed
+36
-3
lines changed- src/Lean/Elab/Do
- tests/elab
2 files changed
+36
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
| 182 | + | |
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
186 | 187 | | |
187 | | - | |
| 188 | + | |
| 189 | + | |
188 | 190 | | |
189 | 191 | | |
190 | 192 | | |
| |||
263 | 265 | | |
264 | 266 | | |
265 | 267 | | |
266 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
267 | 279 | | |
268 | 280 | | |
269 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments