diff options
author | johnvg | 2015-11-27 13:54:56 +0000 |
---|---|---|
committer | johnvg | 2015-11-27 13:54:56 +0000 |
commit | 57498fefb8a206919860cbf7ae1d201faffbd5c0 (patch) | |
tree | 26b69cd96834ee74a9faa306a9b21b6283b94121 | |
parent | use new label names for _indirection (instead of old names) (diff) |
only allow infix constructor with arity 2, otherwise the compiler may crash when pattern matching
git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@2669 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
-rw-r--r-- | frontend/parse.icl | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/frontend/parse.icl b/frontend/parse.icl index 0b02282..55720e4 100644 --- a/frontend/parse.icl +++ b/frontend/parse.icl @@ -2217,11 +2217,20 @@ where want_constructor :: ![ATypeVar] !Token !ParseState -> (.ParsedConstructor,!ParseState) want_constructor exi_vars token pState # token = basic_type_to_constructor token - # (pc_cons_ident, pc_cons_prio, pc_cons_pos, pState) = want_cons_name_and_prio token pState + # (pc_cons_ident, pc_cons_prio, pc_cons_pos, pState) = want_cons_name_and_prio token pState (pc_arg_types, pState) = parseList tryBrackSAType pState + pState = case pc_cons_prio of + NoPrio + -> pState + Prio _ _ + -> case pc_arg_types of + [_,_] + -> pState + _ + -> parseErrorSimple pc_cons_ident.id_name "arity of an infix constructor should be 2" pState (pc_context,pState) = optional_constructor_context pState cons = { pc_cons_ident = pc_cons_ident, pc_arg_types = atypes_from_satypes pc_arg_types, pc_args_strictness=strictness_from_satypes pc_arg_types, - pc_context = pc_context, pc_cons_arity = length pc_arg_types, pc_cons_prio = pc_cons_prio, pc_exi_vars = exi_vars, pc_cons_pos = pc_cons_pos} + pc_context = pc_context, pc_cons_arity = length pc_arg_types, pc_cons_prio = pc_cons_prio, pc_exi_vars = exi_vars, pc_cons_pos = pc_cons_pos} = (cons,pState) want_newtype_constructor :: ![ATypeVar] !Token !ParseState -> (.ParsedConstructor,!ParseState) |