-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
Description
Seems there's a bug in case simplify? I'm using d5dfda2
➤ ../trunk-pmlc/bin/pmlc -Cbom.check-all=true fib-datatype.pml
***** Bogus BOM in Main after case-simplify *****
** invalid cast:(_t<D762>#2:int) = (int)left<F8FC>#5:any
** invalid cast:(_t<D773>#1:int) = (int)right<F8FD>#7:any
** type mismatch in return from fib<F8FA>#3.3
== expected any
== but found int
** type mismatch in return from fib<F8FA>#3.3
== expected any
== but found int
** invalid cast:(_t<D751>#1:int) = (int)right<F8FD>#7:any
** type mismatch in return from fib<F8FA>#3.3
== expected any
== but found int
** type mismatch in return from fib<F8FA>#3.3
== expected any
== but found int
** invalid cast:(_t<D78A>#1:int) = (int)ans<F90E>#3:any
broken BOM dumped to broken-BOM
bom/check-bom.sml:544.11-544.28: Fail: broken BOM
See fib-datatype.pml below:
datatype fib_result
= Zero
| One
| Val of int
fun add a b = (case (a, b)
of (Zero, b) => b
| (a, Zero) => a
| (One, One) => Val 2
| (One, Val b) => Val (b+1)
| (Val a, One) => Val (a+1)
| (Val a, Val b) => Val (a+b)
(* end case *))
fun show a = (case a
of Zero => "0"
| One => "1"
| Val a => Int.toString a
(* end case *))
fun fib n = (case n
of 0 => Zero
| 1 => One
| _ => let
val left = fib (n-1)
val right = fib (n-2)
in
add left right
end
(* end case *))
val i2s = Int.toString
val n = 30 (* https://oeis.org/A000045/list *)
val ans = fib n
val _ = print ("fib(" ^ i2s n ^ ") = " ^ show ans ^ "\n")