From 4861ebb08ccd3e13af19b9c12f2164b66a5d2bb0 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Thu, 26 Jul 2018 16:30:59 +0100 Subject: Some tweaks to not and or patterns - Fix ambiguities in parser.mly - Ensure that no new identifiers are bound in or-patterns and not-patterns, by adding a no_bindings switch to the environment. These patterns shouldn't generate any bogus flow typing constraints because we just pass through the original environment without adding any possible constraints (although this does mean we don't get any flow typing from negated numeric literals right now, which is a TODO). - Reformat some code to match surrounding code. - Add a typechecking test case for not patterns - Add a typechecking test case for or patterns At least at the front end everything should work now, but we need to do a little bit more to rewrite these patterns away for lem etc. --- src/parser.mly | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/parser.mly') diff --git a/src/parser.mly b/src/parser.mly index 2a05c013..694a4669 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -676,6 +676,8 @@ pat_string_append: pat1: | atomic_pat { $1 } + | atomic_pat Bar pat1 + { mk_pat (P_or ($1, $3)) $startpos $endpos } | atomic_pat At pat_concat { mk_pat (P_vector_concat ($1 :: $3)) $startpos $endpos } | atomic_pat ColonColon pat1 @@ -710,8 +712,6 @@ atomic_pat: { mk_pat (P_lit $1) $startpos $endpos } | id { mk_pat (P_id $1) $startpos $endpos } - | pat Bar pat - { mk_pat (P_or ($1, $3)) $startpos $endpos } | kid { mk_pat (P_var (mk_pat (P_id (id_of_kid $1)) $startpos $endpos, mk_typ (ATyp_var $1) $startpos $endpos)) $startpos $endpos } -- cgit v1.2.3