为了自检示例,我运行了以下代码:
assert :: Bool -> Bool -> String -> IO ()
assert actual expected description
| expected == actual = do { print "" } -- need a better way to do nothing
| otherwise = error description
main _ = do
assert (odd 2) false "2 is not odd"
assert (odd 3) true "3 is odd"
我知道这并不完美(建议非常受欢迎),但当前的问题是,当我将断言的定义放入模块 util.Assertions 时,使用两个断言无法编译
build/realworld/chapter2/FunctionApplication.java:168: error: cannot access ?
Assertions.?._assert?.apply(
^
class file for util.Assertions$? not found
1 error
E .../Real_World_Frege/chapter2/FunctionApplication.fr:24: java compiler errors are most likely caused by erronous
native definitions
它在我只有一个断言时起作用,因此类本身在 CP 上,并且模块导入原则上起作用。怎么了?