From 5bfbb47591e46139c10ff3e674731de6061ec872 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Fri, 24 Aug 2018 18:22:12 +0100 Subject: Fix rewriter issues Allow pat_lits rewrite to map L_unit to wildcard patterns, rather than introducing eq_unit tests as guards. Add a fold_function and fold_funcl functions in rewriter.ml that apply the pattern and expression algebras to top-level functions, which means that they correctly get applied to top-level function patterns when they are used. Currently modifying the re-writing passes to do this introduces some bugs which needs investigated further. The current situation is that top-level patterns and patterns elsewhere are often treated differently because rewrite_exp doesn't (and indeed cannot, due to how the re-writer is structured) rewrite top level patterns. Fix pattern completeness check for unit literals Fix a bug in Sail->ANF transform where blocks were always annotated with type unit incorrectly. This caused issues in pattern literal re-writes where the guard was a block returning a boolean. A test case for this is added as test/c/and_block.sail. Fix a bug caused by nested polymorphic function calls and matching in top-level patterns. Test case is test/c/tl_poly_match.sail. Pass location info through codegen_conversion for better error reporting --- src/bytecode_util.ml | 1 + 1 file changed, 1 insertion(+) (limited to 'src/bytecode_util.ml') diff --git a/src/bytecode_util.ml b/src/bytecode_util.ml index 856c9b47..4ddb0c81 100644 --- a/src/bytecode_util.ml +++ b/src/bytecode_util.ml @@ -222,6 +222,7 @@ let rec ctyp_equal ctyp1 ctyp2 = | CT_vector (d1, ctyp1), CT_vector (d2, ctyp2) -> d1 = d2 && ctyp_equal ctyp1 ctyp2 | CT_list ctyp1, CT_list ctyp2 -> ctyp_equal ctyp1 ctyp2 | CT_ref ctyp1, CT_ref ctyp2 -> ctyp_equal ctyp1 ctyp2 + | CT_poly, CT_poly -> true | _, _ -> false let rec ctyp_unify ctyp1 ctyp2 = -- cgit v1.2.3