diff options
| author | Alasdair Armstrong | 2018-09-10 16:53:39 +0100 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-09-10 16:58:00 +0100 |
| commit | 11618832e390711c198f816c1b7fb38e8c79a6aa (patch) | |
| tree | b8079d00ae37abf4581ce3de07f0b7b9690f362e /src/constant_fold.ml | |
| parent | ba30f984f8fd98d9c35b9660d8e7db498369c2b9 (diff) | |
Various fixes
C: Don't print usage message and quit when called with no arguments,
as this is used for testing C output
OCaml: Fix generation of datatypes with multiple type arguments
OCaml: Generate P_cons pattern correctly
C: Fix constant propagation to not propagate letbindings with type
annotations. This behaviour could cause type errors due to how type
variables are introduced. Now we only propagate letbindings when the
type of the propagated variable is guaranteed to be the same as the
inferred type of the binding.
Tests: Add OCaml tests to the C end-to-end tests (which really
shouldn't be in test/c/ any more, something like test/compile might be
better). Currently some issues with reals there like interpreter.
Tests: Rename list.sail -> list_test.sail because ocaml doesn't want
to compile files called list.ml.
Diffstat (limited to 'src/constant_fold.ml')
| -rw-r--r-- | src/constant_fold.ml | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/constant_fold.ml b/src/constant_fold.ml index e9efac68..407bd69a 100644 --- a/src/constant_fold.ml +++ b/src/constant_fold.ml @@ -183,15 +183,15 @@ let rec rewrite_constant_function_calls' ast = | E_if (E_aux (E_lit (L_aux (L_true, _)), _), then_exp, _) -> ok (); then_exp | E_if (E_aux (E_lit (L_aux (L_false, _)), _), _, else_exp) -> ok (); else_exp + (* We only propagate lets in the simple case where we know that + the id will have the inferred type of the argument. For more + complex let bindings trying to propagate them may result in + type errors due to how type variables are bound by let bindings + *) | E_let (LB_aux (LB_val (P_aux (P_id id, _), bind), _), exp) when is_constant bind -> ok (); subst id bind exp - | E_let (LB_aux (LB_val (P_aux (P_typ (typ, P_aux (P_id id, _)), annot), bind), _), exp) - when is_constant bind -> - ok (); - subst id (E_aux (E_cast (typ, bind), annot)) exp - | _ -> E_aux (e_aux, annot) in let rw_exp = { |
