From 019c5a18384c3800de3435e637cfee7cbc8fd551 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Wed, 17 Jul 2019 15:56:09 +0100 Subject: Add another test case --- test/typecheck/pass/poly_vector.sail | 24 ++++++++++++++++++++++++ test/typecheck/pass/poly_vector/v1.expect | 18 ++++++++++++++++++ test/typecheck/pass/poly_vector/v1.sail | 24 ++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 test/typecheck/pass/poly_vector.sail create mode 100644 test/typecheck/pass/poly_vector/v1.expect create mode 100644 test/typecheck/pass/poly_vector/v1.sail diff --git a/test/typecheck/pass/poly_vector.sail b/test/typecheck/pass/poly_vector.sail new file mode 100644 index 00000000..93676a1b --- /dev/null +++ b/test/typecheck/pass/poly_vector.sail @@ -0,0 +1,24 @@ +default Order dec + +$include + +$ifndef FEATURE_BITVECTOR_TYPE +type bitvector('n, 'ord) = vector('n, 'ord, bit) +$endif + +val "to_generic" : forall 'n. bitvector('n, dec) -> vector('n, dec, bit) + +val "print_endline" : string -> unit + +function my_length forall 'n ('a : Type). (xs: vector('n, dec, 'a)) -> int('n) = { + length(xs) +} + +function main() -> unit = { + let xs : bits(32) = 0xFFFF_FFFF; + if my_length(to_generic(xs)) == 32 then { + print_endline("ok") + } else { + print_endline("false") + } +} \ No newline at end of file diff --git a/test/typecheck/pass/poly_vector/v1.expect b/test/typecheck/pass/poly_vector/v1.expect new file mode 100644 index 00000000..9c4da56f --- /dev/null +++ b/test/typecheck/pass/poly_vector/v1.expect @@ -0,0 +1,18 @@ +Type error: +[poly_vector/v1.sail]:19:5-24 +19 | if my_length(xs) == 32 then { +  | ^-----------------^ +  | No overloading for (operator ==), tried: +  | * eq_int +  | No valid casts resulted in unification +  | * eq_bit +  | No valid casts resulted in unification +  | * eq_bool +  | No valid casts resulted in unification +  | * eq_unit +  | No valid casts resulted in unification +  | * eq_bit +  | No valid casts resulted in unification +  | * eq_bits +  | No valid casts resulted in unification +  | diff --git a/test/typecheck/pass/poly_vector/v1.sail b/test/typecheck/pass/poly_vector/v1.sail new file mode 100644 index 00000000..cad74ddc --- /dev/null +++ b/test/typecheck/pass/poly_vector/v1.sail @@ -0,0 +1,24 @@ +default Order dec + +$include + +$ifndef FEATURE_BITVECTOR_TYPE +type bitvector('n, 'ord) = vector('n, 'ord, bit) +$endif + +val "to_generic" : forall 'n. bitvector('n, dec) -> vector('n, dec, bit) + +val "print_endline" : string -> unit + +function my_length forall 'n ('a : Type). (xs: vector('n, dec, 'a)) -> int('n) = { + length(xs) +} + +function main() -> unit = { + let xs : bits(32) = 0xFFFF_FFFF; + if my_length(xs) == 32 then { + print_endline("ok") + } else { + print_endline("false") + } +} \ No newline at end of file -- cgit v1.2.3