From 57498fefb8a206919860cbf7ae1d201faffbd5c0 Mon Sep 17 00:00:00 2001 From: johnvg Date: Fri, 27 Nov 2015 13:54:56 +0000 Subject: 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 --- frontend/parse.icl | 13 +++++++++++-- 1 file 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) -- cgit v1.2.3