diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-10-13 04:45:02 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-10-13 04:45:02 +0000 |
commit | dec8c49d8e46c8454d58c0dc8a84bfd49367b89d (patch) | |
tree | 1df05d83fbfdc04706e144179a4718767f04caa7 | |
parent | 162f86dcdf252a8ba4b43c8f11ca248a58d5c56a (diff) | |
download | perl-MDK-Common-dec8c49d8e46c8454d58c0dc8a84bfd49367b89d.tar perl-MDK-Common-dec8c49d8e46c8454d58c0dc8a84bfd49367b89d.tar.gz perl-MDK-Common-dec8c49d8e46c8454d58c0dc8a84bfd49367b89d.tar.bz2 perl-MDK-Common-dec8c49d8e46c8454d58c0dc8a84bfd49367b89d.tar.xz perl-MDK-Common-dec8c49d8e46c8454d58c0dc8a84bfd49367b89d.zip |
- check push arguments
- add a test for pop arguments
-rw-r--r-- | perl_checker.src/parser_helper.ml | 7 | ||||
-rw-r--r-- | perl_checker.src/test/various_errors.t | 8 |
2 files changed, 15 insertions, 0 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml index 0be9353..858dd80 100644 --- a/perl_checker.src/parser_helper.ml +++ b/perl_checker.src/parser_helper.ml @@ -910,6 +910,13 @@ let call_raw force_non_builtin_func (e, para) = | [ List [ Deref(I_array, _) ] ] -> () | _ -> warn_rule (f ^ " is expecting an array and nothing else")) + | "push" | "unshift" -> + (match para with + | Deref(I_array, _) :: l + | [ List (Deref(I_array, _) :: l) ] -> + if l = [] then warn_rule ("you must give some arguments to " ^ f) + | _ -> warn_rule (f ^ " is expecting an array")) + | "system" -> (match un_parenthesize_full_l para with | [ String(l, _) ] -> diff --git a/perl_checker.src/test/various_errors.t b/perl_checker.src/test/various_errors.t index af21eb4..901612f 100644 --- a/perl_checker.src/test/various_errors.t +++ b/perl_checker.src/test/various_errors.t @@ -25,6 +25,14 @@ join(@l) first argument of join() must be a scal join(',', 'foo') join('...', $foo) is the same as $foo +push @l you must give some arguments to push + +push $xxx, 1 push is expecting an array + +pop @l, 1 pop is expecting an array and nothing else + +pop $xxx pop is expecting an array and nothing else + system(qq(foo "$xxx")) instead of quoting parameters you should give a list of arguments my (@l2, $xxx) = @l; @l2 takes all the arguments, $xxx is undef in any case |