lean2/tests/lua/tc4.lua
Leonardo de Moura 7c0cc3111a fix(kernel/type_checker): we must use different caches for infer_type and check
The new test tc4.lua exposes the problem being fixed.
We need separate caches otherwise we may mistakenly assume that an expression was already checked by the type checker, while only its type was inferred.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-05-15 13:53:11 -07:00

17 lines
603 B
Lua

local env = empty_environment()
env = add_decl(env, mk_var_decl("or", mk_arrow(Bool, Bool, Bool)))
env = add_decl(env, mk_var_decl("A", Bool))
local Or = Const("or")
local A = Const("A")
local B = Const("B")
local tc = type_checker(env)
local F = Or(A, B)
assert(tc:infer(F) == Bool)
assert(not pcall(function()
-- The following test must fail since B is not
-- declared in env.
-- This test make sure that infer and check are
-- not sharing the same cache.
print(tc:check(F))
end
))