Skip to content

Commit c8edd24

Browse files
committed
chore: update to Lean v4.12.0
1 parent fe6caab commit c8edd24

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

Lyre/Builder.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def mkCtor (stx : Lyre.CtorInfo) (argStxs : Array Lyre.Arg) : BuilderM (IR.CtorI
204204
| throwWithSyntax (ref := ctor) stx s!"ill-formed IR constructor name '{ctor.getId}'"
205205
let name ← id do
206206
let some ctorId := ctorId? | return Name.anonymous
207-
let name ← resolveGlobalConstNoOverloadWithInfo ctorId
207+
let name ← realizeGlobalConstNoOverloadWithInfo ctorId
208208
let some (.ctorInfo {cidx := ecidx, ..}) := (← getEnv).find? name
209209
| throwWithSyntax (ref := ctorId) stx m!"'{name}' is not a constructor"
210210
if cidx != ecidx then
@@ -244,7 +244,7 @@ def mkExpr (stx : Lyre.Expr) : BuilderM (IR.Expr × Option IRType) := do
244244
| `(irExpr|sproj[$n,$o] $x $[: $ty?]?) =>
245245
return (.sproj n.getNat o.getNat (← getVarId x), ← ty?.mapM mkType)
246246
| `(fap|$c:ident $ys*) =>
247-
let name ← try resolveGlobalConstNoOverloadWithInfo c catch _ => pure c.getId
247+
let name ← try realizeGlobalConstNoOverloadWithInfo c catch _ => pure c.getId
248248
if let some decl := IR.findEnvDecl (← getEnv) name then
249249
let ty := match decl with
250250
| .fdecl (type := ty) .. | .extern (type := ty) .. => ty

Lyre/Commands.lean

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ namespace Lyre
1414
scoped elab (name := Test.printIr) kw:"#print_ir " id:ident : command => do
1515
let name ← do
1616
try
17-
resolveGlobalConstNoOverloadWithInfo id
17+
liftCoreM <| realizeGlobalConstNoOverloadWithInfo id
1818
catch _ =>
19-
pure <| if rootNamespace.isPrefixOf id.getId
20-
then removeRoot id.getId else (← getCurrNamespace) ++ id.getId
19+
if rootNamespace.isPrefixOf id.getId then
20+
pure <| removeRoot id.getId
21+
else
22+
pure <| (← getCurrNamespace) ++ id.getId
2123
let some decl := IR.findEnvDecl (← getEnv) name
2224
| throwErrorAt id "no IR found for '{name}'"
2325
logInfoAt kw (IR.declToString decl)
2426

2527
/--
26-
Directly set the Lean IR for a the definition `name`.
27-
The definition most not already have IR. This can be accomplish
28+
Directly set the Lean IR for the definition `name`.
29+
The definition must not already have IR. This can be accomplish
2830
by marking the definition `noncomputable` when declared.
2931
-/
3032
def setAdhoc [Monad m] [MonadEnv m] [MonadError m]
@@ -70,7 +72,7 @@ scoped syntax (name := irImpl)
7072
"ir_impl " ident param* (" : " irType)? " := " stmtSeq : command
7173

7274
elab_rules : command | `(ir_impl $id $ps* $[: $ty?]? := $stmts*) => do
73-
let name ← resolveGlobalConstNoOverloadWithInfo id
75+
let name ← liftCoreM <| realizeGlobalConstNoOverloadWithInfo id
7476
let (ps, ty, body) ← liftTermElabM <| BuilderM.run do
7577
let ps ← ps.mapM mkParam
7678
let (body, bty?) ← mkFnBody stmts

lakefile.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def runLean (file : FilePath) : ScriptM PUnit := do
1515
if exitCode ≠ 0 then
1616
IO.Process.exit exitCode.toUInt8
1717

18+
@[test_driver]
1819
script test do
1920
runLean <| "tests" / "basic.lean"
2021
return 0

lean-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
leanprover/lean4:4.4.0
1+
leanprover/lean4:v4.12.0

tests/basic.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ ir_impl myAdd (m : @& obj) (n : @& obj) :=
88
let x := Nat.add m n
99
ret x
1010

11+
/-- info: 3 -/
12+
#guard_msgs in
1113
#eval myAdd 1 2
1214

1315
noncomputable opaque getNum (_ : Unit) : Nat
@@ -16,6 +18,8 @@ ir_impl getNum (_ : obj) :=
1618
let n := 2 : obj
1719
ret n
1820

21+
/-- info: 2 -/
22+
#guard_msgs in
1923
#eval getNum ()
2024

2125
noncomputable opaque throwMyError : IO Unit
@@ -26,6 +30,8 @@ ir_impl throwMyError (w : obj) :=
2630
let res := ctor_1[EStateM.Result.error] err w
2731
ret res
2832

33+
/-- info: error: myError -/
34+
#guard_msgs in
2935
#eval throwMyError.toBaseIO
3036

3137
noncomputable opaque getNil (α : Type u) : List α
@@ -34,4 +40,6 @@ ir_impl getNil (_ : ◾) :=
3440
let l : obj := List.nil
3541
ret l
3642

43+
/-- info: [] -/
44+
#guard_msgs in
3745
#eval getNil Nat

0 commit comments

Comments
 (0)