From 91730391723e88af3951ee6e6d79896ae9269796 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 2 Apr 2003 11:59:00 +0000 Subject: simplify handling of variables declared in "if (...) ..." to meet perl's way. eg: if (my $i = foo()) { } else { $i; # accessing $i here is allowed } if (my $i = foo()) { } elsif ($i = bar()) { # don't use "my" for $i since it's already in scope } --- perl_checker.src/global_checks.ml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'perl_checker.src') diff --git a/perl_checker.src/global_checks.ml b/perl_checker.src/global_checks.ml index 2d74445..0ec9a62 100644 --- a/perl_checker.src/global_checks.ml +++ b/perl_checker.src/global_checks.ml @@ -243,12 +243,10 @@ let check_variables vars t = let vars = check_variables_ vars expr in let vars = check_variables_ vars (Block (my :: block)) in Some vars - | Call_op(op, cond :: Block first_bl :: other, _) when op = "if" || op = "while" || op = "unless" || op = "until" -> + | Call_op(op, l, _) when op = "if" || op = "while" || op = "unless" || op = "until" -> let vars' = { vars with my_vars = [] :: vars.my_vars ; our_vars = [] :: vars.our_vars } in - let vars' = check_variables_ vars' cond in - let vars' = List.fold_left check_variables_ vars' first_bl in + let vars' = List.fold_left check_variables_ vars' l in check_unused_local_variables vars' ; - let vars = List.fold_left check_variables_ vars other in Some vars | Sub_declaration(Ident(fq, name, pos) as ident, _proto, Block l) -> -- cgit v1.2.1