Skip to content
Browse files

[fix] compiler, syntax: let and bindings was bad rewrited by the pars…

…er, (breaks semantic bug still in classic parser)
  • Loading branch information...
1 parent 6ff9907 commit f52dac9e295aaead6f220105c2e6a8caf23526f9 @BourgerieQuentin BourgerieQuentin committed Feb 10, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 opalang/js_syntax/opa_parser.trx
View
12 opalang/js_syntax/opa_parser.trx
@@ -533,8 +533,16 @@ binding_expr <- (=deco(block_inner))
binding <-
/ Opa_lexer.REC?:r (=list1(binding_pattern, Opa_lexer.AND)):binds expr:expr
{{
- let binds = List.concat_map pat_in_to_simple_bindings binds in
- rewrite_letin (Option.is_some r) binds expr
+ let heads, tails =
+ List.fold_right
+ (fun bind (heads, tails) ->
+ match pat_in_to_simple_bindings bind with
+ | [] -> assert false
+ | h::t -> h::heads, t::tails) binds ([], [])
+ in
+ let tails = rewrite_letin (Option.is_some r) (List.flatten tails) expr in
+ let heads = rewrite_letin (Option.is_some r) heads (tails, copy_label (label expr)) in
+ heads
}}

0 comments on commit f52dac9

Please sign in to comment.
Something went wrong with that request. Please try again.