summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/monomorphise.ml5
-rw-r--r--test/mono/rewrites.sail1
2 files changed, 4 insertions, 2 deletions
diff --git a/src/monomorphise.ml b/src/monomorphise.ml
index d86db99d..7c958ffe 100644
--- a/src/monomorphise.ml
+++ b/src/monomorphise.ml
@@ -2936,8 +2936,9 @@ let rec rewrite_app env typ (id,args) =
in
let try_cast_to_typ (E_aux (e,(l, _)) as exp) =
let (size,order,bittyp) = vector_typ_args_of (Env.base_typ_of env typ) in
- match size with
- | Nexp_aux (Nexp_constant _,_) -> E_cast (typ,exp)
+ (* vector_typ_args_of might simplify size, so rebuild the type even if it's constant *)
+ match size with
+ | Nexp_aux (Nexp_constant c,_) -> E_cast (bitvector_typ (nconstant c) order, exp)
| _ -> match solve_unique env size with
| Some c -> E_cast (bitvector_typ (nconstant c) order, exp)
| None -> e
diff --git a/test/mono/rewrites.sail b/test/mono/rewrites.sail
index b08af90f..5f409cdf 100644
--- a/test/mono/rewrites.sail
+++ b/test/mono/rewrites.sail
@@ -23,4 +23,5 @@ function run() = {
assert(sign_ext_fun(x, z, 32) == 0x00000200);
assert(sail_zero_extend(y[7..4] @ sail_zeros(8), 32) == 0x00000800);
assert(sign_ext_fun(y, z, 32) == 0xfffff800);
+ assert(sail_ones(i) @ sail_zeros(9) == 0xfe00);
}