diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-06-16 17:52:44 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-06-16 17:52:44 -0400 |
commit | 167258efc314f978a4cd5f248b8d3df2f36f9d6d (patch) | |
tree | 03a63951b832edfdb7a5c7cb9c05345c0f097248 /src | |
parent | b93aa3fc0a1aebc3be9e9a69f926eae0300ba253 (diff) |
Fix a variable capture bug in nested JavaScript; some more list stuff
Diffstat (limited to 'src')
-rw-r--r-- | src/elab_err.sml | 4 | ||||
-rw-r--r-- | src/jscomp.sml | 12 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/elab_err.sml b/src/elab_err.sml index f6fec25b..dc34560b 100644 --- a/src/elab_err.sml +++ b/src/elab_err.sml @@ -218,7 +218,7 @@ fun expError env err = ("Type", p_con env c)]) co) | Unresolvable (loc, c) => (ErrorMsg.errorAt loc "Can't resolve type class instance"; - eprefaces' [("Class constraint", p_con env c), + eprefaces' [("Class constraint", p_con env c)(*, ("Class database", p_list (fn (c, rules) => box [P.p_con env c, PD.string ":", @@ -228,7 +228,7 @@ fun expError env err = PD.string ":", space, P.p_con env c]) rules]) - (E.listClasses env))]) + (E.listClasses env))*)]) | IllegalRec (x, e) => (ErrorMsg.errorAt (#2 e) "Illegal 'val rec' righthand side (must be a function abstraction)"; eprefaces' [("Variable", PD.string x), diff --git a/src/jscomp.sml b/src/jscomp.sml index 9f0a7a1b..79ae814e 100644 --- a/src/jscomp.sml +++ b/src/jscomp.sml @@ -980,12 +980,18 @@ fun process file = jsE inner (e, st)) | EJavaScript (_, e) => let + val locals = List.tabulate + (varDepth e, + fn i => str ("var _" ^ Int.toString (len + inner + i) ^ ";")) + val (e, st) = jsE inner (e, st) in foundJavaScript := true; - (strcat [str "cs(function(){return ", - compact inner e, - str "})"], + (strcat (str "cs(function(){" + :: locals + @ [str "return ", + compact inner e, + str "})"]), st) end |