Permalink
Browse files

[fix] pass_simplifyMagic: wrong order of specializers caused wierd re…

…cursions to appear in the code

when adding @stringifiers
  • Loading branch information...
1 parent a63f923 commit 98cd5617867f20dc6a8cf3c5600a82ed02f2cdae Valentin Gatien-Baron committed Jun 30, 2011
Showing with 7 additions and 3 deletions.
  1. +1 −1 qmljsimp/imp_Code.ml
  2. +6 −2 qmlpasses/pass_SimplifyMagic.ml
View
@@ -447,7 +447,7 @@ let analyse_tail_recursion bindings =
(match expr with
| Q.Lambda (_, _, Q.Lambda (_, _, e))
| Q.Lambda (_, _, e) -> aux i e
- | _ -> assert false);
+ | _ -> OManager.i_error "Non lambda in a recursion: %a@." QmlPrint.pp#expr expr);
#<If:JS_IMP$contains "tailcall">
Format.printf "@."
#<End>
@@ -189,12 +189,16 @@ let rewrite_expr env gamma annotmap code =
| _ -> tra annotmap e in
QmlAstWalk.Expr.traverse_foldmap aux annotmap code
-let process_code ?(specialized_env=IdentMap.empty) gamma annotmap code =
+let empty_env = IdentMap.empty
+let process_code ?(specialized_env=empty_env) gamma annotmap code =
let (env,annotmap), code = build_env specialized_env gamma annotmap code in
R.save annotmap env;
#<If:SIMPLIFYMAGIC_DISABLE>
annotmap, code
#<Else>
- let annotmap, env = R.load annotmap env in
+ let annotmap, env2 = R.load annotmap empty_env in
+ let env = IdentMap.merge (@) env2 env in (* the old env has priority over the current one
+ * so that Date.to_string doesn't override intToString
+ * in the package date *)
QmlAstWalk.CodeExpr.fold_map (rewrite_expr env gamma) annotmap code
#<End>

0 comments on commit 98cd561

Please sign in to comment.