diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2003-04-02 11:59:00 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2003-04-02 11:59:00 +0000 |
commit | afaf7225e1f52693ef6047e345ae2e6023c9ebc9 (patch) | |
tree | 426e87b43d77ec9f0a660c9123c01735ecbb4196 /perl_checker.src | |
parent | ee7cf6262287e1626d94fab23d731baced96969f (diff) | |
download | perl-MDK-Common-afaf7225e1f52693ef6047e345ae2e6023c9ebc9.tar perl-MDK-Common-afaf7225e1f52693ef6047e345ae2e6023c9ebc9.tar.gz perl-MDK-Common-afaf7225e1f52693ef6047e345ae2e6023c9ebc9.tar.bz2 perl-MDK-Common-afaf7225e1f52693ef6047e345ae2e6023c9ebc9.tar.xz perl-MDK-Common-afaf7225e1f52693ef6047e345ae2e6023c9ebc9.zip |
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
}
Diffstat (limited to 'perl_checker.src')
-rw-r--r-- | perl_checker.src/global_checks.ml | 6 |
1 files changed, 2 insertions, 4 deletions
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) -> |