-
I'm not sure exactly why I'm seeing the error that I am, but I seem to be seeing an error when trying to say that a function with dependently typed arguments is of the same type as a function of the same shape with implicitly typed arguments (code below). It type checks ok if I change the dependently typed arguments to be of a static type. I get a different (slightly more informative) error message if I move the refinement into my functions argument. It becomes even more informative if I print implicits, but it looks like the implicit type inferred is the unrefined type. The error message I get with print implicits (using the explicit refinement) is: Does anyone know why I'm seeing these errors? Does the module Test
open FStar.Bytes
type protocol (#args_1_type: Type) (#args_2_type: Type) (#result_type: Type) =
args_1_type -> args_2_type -> result_type
// Using my dependent type here (lbytes n) results in the error: "(*?u11*) _ is not equal to the expected type n"
assume val test_proto (n: nat) (m: lbytes n) : Tot (lbytes n)
// Whereas if I just use the non-dependent type bytes, it type checks ok
//assume val test_proto (n: nat) (m: bytes) : Tot bytes
// If I make the refinement explicit here, I get a new error message that states that the SMT solver can't prove that test_proto is of type protocol
//assume val test_proto (n: nat) (m: bytes{length m == n}) : Tot (r: bytes{length r == n})
#push-options "--print_implicits"
let test_proto_wrapper : protocol =
test_proto
#pop-options |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @klinvill: The issue here is that while
to reflect the dependence of the type of the second argument and return type on the first argument, then it checks out. The refinement version also works with this. (The error message |
Beta Was this translation helpful? Give feedback.
Hi @klinvill:
The issue here is that while
test_proto
has a dependent type, the typeprotocol
is not dependent. If we change theprotocol
type to:to reflect the dependence of the type of the second argument and return type on the first argument, then it checks out. The refinement version also works with this.
(The error message
(*?u11*) _ is not equal to the expected type n
could be better.)