Permalink
Browse files

[fix] syntax: Syntactic sugar on list should not coerce into list

  • Loading branch information...
1 parent 534ca4d commit 11f17b272676ac0059483fd236e41aaac6f0a190 @BourgerieQuentin BourgerieQuentin committed with OpaOnWindowsNow Dec 1, 2011
@@ -905,15 +905,20 @@ let computed_string l = directive `string l
* stuff on list put here because they need coerce_name_expr
*)
let list_nil label = coerce_name_expr (record [("nil",void label)]) Opacapi.Types.list
+let list_nil_no_coerce label = (record [("nil",void label)])
let list_nil_pat label = coerce_name_pat (record_pat [("nil",void_pat label)]) Opacapi.Types.list
let list_cons e1 e2 = coerce_name_expr (record [("hd",e1);("tl",e2)]) Opacapi.Types.list
+let list_cons_no_coerce e1 e2 = (record [("hd",e1);("tl",e2)])
let list_cons_pat e1 e2 = coerce_name_pat (record_pat [("hd",e1);("tl",e2)]) Opacapi.Types.list
let list_pat_of_pat_list ?tl l label : string pat =
let tl = match tl with None -> list_nil_pat label | Some tl -> tl in
List.fold_right list_cons_pat l tl
let list_expr_of_expr_list ?tl l label =
let tl = match tl with None -> list_nil label | Some tl -> tl in
List.fold_right list_cons l tl
+let list_expr_of_expr_list_no_coerce ?tl l label =
+ let tl = match tl with None -> list_nil_no_coerce label | Some tl -> tl in
+ List.fold_right list_cons_no_coerce l tl
let list_expr_of_expr_list_unsafe l =
assert (l <> []);
let pos = union_annot_list l in list_expr_of_expr_list l pos
@@ -244,6 +244,8 @@ val list_pat_of_pat_list :
?tl:(string pat) -> string pat list -> annot -> string pat
val list_expr_of_expr_list :
?tl:(string,'a) expr -> (string, [> `coerce ] as 'a) expr list -> annot -> (string, 'a) expr
+val list_expr_of_expr_list_no_coerce :
+ ?tl:(string,'a) expr -> (string, [> `coerce ] as 'a) expr list -> annot -> (string, 'a) expr
val list_expr_of_expr_list_unsafe : (string, [> `coerce ] as 'a) expr list -> (string, 'a) expr(**Fails if the list is empty*)
val list_constructors_of_string_list: (string * annot) list -> annot -> (string, [> `coerce ]) expr
@@ -922,9 +922,9 @@ lambda <- Opa_lexer.FUNCTION (=type_maybe(lambda_no_function:lambda {{lambda}}))
/** List **/
list <-
/ lbracket (=list0(Action.action,comma)):l pos:p comma? (Opa_lexer.BAR expr:e {{e}})?:tl rbracket
- {{ undecorate (list_expr_of_expr_list ?tl l p) }}
+ {{ undecorate (list_expr_of_expr_list_no_coerce ?tl l p) }}
/ lbracket (=list0(expr, comma)):l pos:p comma? (Opa_lexer.BAR expr:e {{e}})?:tl rbracket
- {{ undecorate (list_expr_of_expr_list ?tl l p) }}
+ {{ undecorate (list_expr_of_expr_list_no_coerce ?tl l p) }}
(* ******************************************************************)

0 comments on commit 11f17b2

Please sign in to comment.