-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 1559 #1561
Conversation
@vouillon, do you have time to comment on the current approach ? |
I tested 3556f36 locally and it fixes the issue with the actual code as well as the example I posted. Thank you! Happy to test other revisions as well if there are other ideas for solving. |
I'd like to have a single pass to compute all free variables of closures. edit: this has been implemented |
@rickyvetter, I've pushed an alternative fix. |
List.iter params ~f:(fun x -> Code.Var.ISet.add bound x); | ||
iter_block_bound_vars (fun x -> Code.Var.ISet.add bound x) block; | ||
List.iter args ~f:using; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we move these two lines outside of function traverse
?
List.iter params ~f:(fun x -> Code.Var.ISet.add bound x);
List.iter args ~f:using;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, fixed in #1565
CHANGES: ## Features/Changes * Mics: fix support for OCaml 5.2 * Compiler: no longer rely on IIFE for scoping variable inside loops * Compiler: avoid parsing bytecode sections twice, jsoo counter part of ocaml#12599 * Lib: add ellipse to canvasRenderingContext2D (@FayCarsons, ocsigen/js_of_ocaml#1555) ## Bug fixes * Compiler: fix global dead code elimination in a toplevel context * Compiler: fix exit-loop-early optim in presence of closure (ocsigen/js_of_ocaml#1561) * Compiler: remove quadratic behavior in generate.ml (ocsigen/js_of_ocaml#1531, ocsigen/js_of_ocaml#1567)
Fixing #1559
Exiting a for loop too early might result in invalid scope for functions declared inside the for-loop.
A function declaration inside inside a block is scoped to that block (in strict mode) and won't be visible outside.
A quick fix is to simply disable the exit-loop-early optimization until one find a proper fix for it.