Idris2
Idris2 copied to clipboard
Exception: attempt to apply non-procedure 0
The following program crashes with scheme exception "attempt to apply non-procedure 0":
bug : Int -> Bool
bug a =
let f = \y => case y == a of { True => True ; False => False }
in or [ f y | y <- [0..10] ]
main : IO ()
main = printLn (bug 5)
I suspect this has to do with automatic delay/force insertion:
-- does not typecheck:
-- "Can't solve constraint between: Bool and Lazy Bool."
bug1 : Int -> Bool
bug1 a =
let f = \y => y == a
in or [ f y | y <- [0..10] ]
-- typechecks and works
bug2 : Int -> Bool
bug2 a =
let f = \y => y == a
in or [ delay (f y) | y <- [0..10] ]
-- also works
bug3 : Int -> Bool
bug3 a =
let f = \y => case y == a of { True => True ; False => False }
in or [ delay (f y) | y <- [0..10] ]
Steps to Reproduce
Load the very first snippet above into the REPL, and run :exec main
.
I used the chez backend with Chez Scheme Version 9.5.7.
Expected Behavior
Prints True
.
Observed Behavior
Crashes with
Exception: attempt to apply non-procedure 0