-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This resolves an issue which I misdiagnosed, causing me to add unnecessary cases to Env_js.merge_env, which could mask other real errors. What's happening here: We enter a catch clause, which pushes a new lex scope. Before we can pop the lex scope, we hit an abnormal and jump away. Then, we merge the env that has a dangling lex scope on top. In general, we run this risk whenever we push a lex scope and then process statements that might raise. I have convinced myself that no other code that calls merge_env will hit this specific case, but a generalized approach would be nice, too.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1350,8 +1350,13 @@ and statement cx type_params_map = Ast.Statement.( | |
Env_js.push_lex (); | ||
Scope.Entry.(Env_js.bind_implicit_let | ||
~state:Initialized CatchParamBinding cx name t r); | ||
List.iter (statement_decl cx type_params_map) b.Block.body; | ||
toplevels cx type_params_map b.Block.body; | ||
Abnormal.exception_handler | ||
(fun () -> | ||
List.iter (statement_decl cx type_params_map) b.Block.body; | ||
toplevels cx type_params_map b.Block.body) | ||
(fun exn -> | ||
Env_js.pop_lex (); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bhosmer
Contributor
|
||
Abnormal.raise_exn exn); | ||
Env_js.pop_lex () | ||
|
||
| loc, Identifier (_, { Ast.Identifier.name; _ }) -> | ||
|
Yes! Perfect. This is an occupational hazard when using exceptions as part of the normal control flow - similar problems show up in the speculative plumbing for unions and intersections in
flow_js
.Oops, not quite perfect... I think you need to pop back to the topmost
VarScope
, right?