Fix bug where tuples are destructured with the members in the wrong order

This commit is contained in:
John David Pressman 2019-12-03 10:49:58 -08:00
parent b9a2eab834
commit 085a756ed3
3 changed files with 5 additions and 4 deletions

View File

@ -600,7 +600,8 @@ and simpl_declaration : Raw.declaration -> declaration Location.wrap list result
(* TODO: Improve this error message *) (* TODO: Improve this error message *)
| other -> fail @@ simplifying_expr other | other -> fail @@ simplifying_expr other
in let%bind decls = in let%bind decls =
bind_map_list process_variable (List.combine variables expr_bind_lst) (* TODO: Rewrite the gen_access_tuple so there's no List.rev *)
bind_map_list process_variable (List.combine variables (List.rev expr_bind_lst))
in ok @@ decls in ok @@ decls
| PPar {region = _ ; value = { lpar = _ ; inside = pt; rpar = _; } } -> | PPar {region = _ ; value = { lpar = _ ; inside = pt; rpar = _; } } ->
(* Extract parenthetical multi-bind *) (* Extract parenthetical multi-bind *)

View File

@ -11,4 +11,4 @@ let main_paren (p: unit) : int = x + y
let foobar : (int * int) = (23 , 42) let foobar : (int * int) = (23 , 42)
let (foo : int) , (bar : int) = foobar let (foo : int) , (bar : int) = foobar
let non_tuple_rhs (p: unit) : int = foo + bar let non_tuple_rhs (p: unit) : int = bar - foo

View File

@ -1215,7 +1215,7 @@ let mligo_let_multiple () : unit result =
in in
let%bind () = let%bind () =
let input = e_unit () in let input = e_unit () in
let expected = e_int 65 in let expected = e_int 19 in
expect_eq program "non_tuple_rhs" input expected expect_eq program "non_tuple_rhs" input expected
in in
ok () ok ()