Skip to content

Commit

Permalink
do not recurse into TFunction when checking var init
Browse files Browse the repository at this point in the history
also run the var init check in the -D analyzer case
  • Loading branch information
Simn committed Jun 19, 2015
1 parent a5dd0c3 commit 5978d0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 4 additions & 0 deletions filters.ml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ let check_local_vars_init e =
| TThrow e | TReturn (Some e) ->
loop vars e;
vars := PMap.map (fun _ -> true) !vars
| TFunction _ ->
(* do not recurse into functions, their code is only relevant when executed *)
()
| _ ->
Type.iter (loop vars) e
in
Expand Down Expand Up @@ -1164,6 +1167,7 @@ let run com tctx main =
(* PASS 1: general expression filters *)
let filters = [
Codegen.AbstractCast.handle_abstract_casts tctx;
check_local_vars_init;
Optimizer.inline_constructors tctx;
Optimizer.reduce_expression tctx;
blockify_ast;
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/src/unit/issues/Issue3861.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package unit.issues;

class Issue3861 extends unit.Test {
function test() {
#if analyzer
var a;
var b = function() return a;
a = 2;
eq(2, b());
#end
}
}

0 comments on commit 5978d0a

Please sign in to comment.