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

Fix Array.empty precompilation #25

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/tac2compiledPrim.ml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ let define name arity f =
registered := (name,arity) :: !registered;
f

(* Adds a thunk *)
let define0 name v =
define name 1 (fun (_:valexpr) -> v)
define name 0 v

let define1 name r0 f =
define name 1 (fun x0 -> f (repr_to r0 x0))
Expand All @@ -56,7 +55,7 @@ let define2 name r0 r1 f =
let define3 name r0 r1 r2 f =
define name 3 (fun x0 x1 x2 -> f (repr_to r0 x0) (repr_to r1 x1) (repr_to r2 x2))

let array_empty = define0 "array_empty" (return (ValBlk (0, [||])))
let array_empty = define0 "array_empty" (ValBlk (0, [||]))

let array_make = define2 "array_make" int valexpr begin fun n x ->
if n < 0 || n > Sys.max_array_length then throw err_outofbounds
Expand Down
2 changes: 1 addition & 1 deletion src/tac2compiledPrim.mli
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
open Ltac2_plugin.Tac2val
open Proofview

val array_empty : valexpr -> valexpr tactic
val array_empty : valexpr
val array_make : valexpr -> valexpr -> valexpr tactic
val array_length : valexpr -> valexpr tactic
val array_set : valexpr -> valexpr -> valexpr -> valexpr tactic
Expand Down
1 change: 1 addition & 0 deletions tests/_CoqProject
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ compiler_bug_6.v
compiler_bug_14.v
compiler_bug_16.v
compiler_bug_17.v
compiler_bug_24.v

-I src

Expand Down
6 changes: 6 additions & 0 deletions tests/compiler_bug_24.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Require Import Ltac2Compiler.Ltac2Compiler.
From Ltac2 Require Import Array.
Ltac2 test () := Array.empty.
Ltac2 Eval Array.length (test ()).
Ltac2 Compile Array.empty.
Ltac2 Eval Array.length (test ()).
Loading