You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[EDIT] I misunderstood something and jumped to conclusions. Polymorphic instantiation works (almost, see #88) fine
Describe the bug
Valid programs annotated with polymorphic types, that is with a Promise(ty, foo) where ty contains a forall, do not typecheck.
For example, executing (with some preparation first, see To reproduce) src/examples/forall.ncl containing
let f = Promise(forall a. (forall b. a -> b -> a), fun x => fun y => x) in
f
with nickel <src/examples/forall.ncl results in the error message:
Typechecked: Err("The following types dont match Arrow(Constant(1), Concrete(Arrow(Constant(2), Constant(1))))
-- Forall(Ident(\"a\"), Concrete(Forall(Ident(\"b\"), Concrete(Arrow(Concrete(Var(Ident(\"a\"))), Concrete(Arrow(Concrete(Var(Ident(\"b\"))), Concrete(Var(Ident(\"a\"))))))))))")
[...]
To Reproduce
This is not directly visible as there is a strict parameter, currently set to false when the typechecker starts, which basically disable typechecking if not set. It corresponds to "dynamic typing" mode, but it should still enforce the type of Promise: why it does not is a different matter. A quick way to isolate this issue is set it to true from the beginning, but then automatically included contracts do not typecheck anymore:
[EDIT] I misunderstood something and jumped to conclusions. Polymorphic instantiation works (almost, see #88) fine
Describe the bug
Valid programs annotated with polymorphic types, that is with a
Promise(ty, foo)
wherety
contains aforall
, do not typecheck.For example, executing (with some preparation first, see To reproduce)
src/examples/forall.ncl
containingwith
nickel <src/examples/forall.ncl
results in the error message:To Reproduce
This is not directly visible as there is a
strict
parameter, currently set tofalse
when the typechecker starts, which basically disable typechecking if not set. It corresponds to "dynamic typing" mode, but it should still enforce the type ofPromise
: why it does not is a different matter. A quick way to isolate this issue is set it to true from the beginning, but then automatically included contracts do not typecheck anymore:strict
totrue
in typecheck.rsinclude_contracts
tofalse
in program.rscargo build
target/debug/nickel <src/examples/forall.ncl
Expected behavior
The program should be accepted by the typechecker:
The text was updated successfully, but these errors were encountered: