summaryrefslogtreecommitdiffstats
path: root/perl_checker.src
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-04-30 09:09:45 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-04-30 09:09:45 +0000
commit7de977a58ea74ceda04eb09e1af2dc209ed8f42c (patch)
tree1a0e8d81c081dca14514f462311f407ca9f49cc6 /perl_checker.src
parenta6ca42ec6122465baef9d2f2ce4051b8d5aaf4a4 (diff)
downloadperl_checker-7de977a58ea74ceda04eb09e1af2dc209ed8f42c.tar
perl_checker-7de977a58ea74ceda04eb09e1af2dc209ed8f42c.tar.gz
perl_checker-7de977a58ea74ceda04eb09e1af2dc209ed8f42c.tar.bz2
perl_checker-7de977a58ea74ceda04eb09e1af2dc209ed8f42c.tar.xz
perl_checker-7de977a58ea74ceda04eb09e1af2dc209ed8f42c.zip
detect "$xxx == undef"
Diffstat (limited to 'perl_checker.src')
-rw-r--r--perl_checker.src/parser_helper.ml9
-rw-r--r--perl_checker.src/test/context.t2
-rw-r--r--perl_checker.src/types.mli2
3 files changed, 9 insertions, 4 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index ca28aa8..9eca21a 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -370,13 +370,14 @@ let word_alone esp =
| "hex" | "length" | "time" | "fork" | "getppid" -> M_int
| "eof" | "wantarray" -> M_int
| "stat" | "lstat" -> M_list
- | "arch" | "quotemeta" | "lc" | "lcfirst" | "uc" | "ucfirst" -> M_string
+ | "arch" | "quotemeta" | "join" | "lc" | "lcfirst" | "uc" | "ucfirst" -> M_string
| "split" -> M_array
| "shift" | "pop" -> M_scalar
| "die" | "return" | "redo" | "next" | "last" -> M_unknown
| "caller" -> M_mixed [M_string ; M_list]
-
+ | "undef" -> M_undef
+
| "ref" -> M_ref M_scalar
| _ -> M_unknown
in mcontext, e
@@ -1044,6 +1045,7 @@ let rec mcontext2s = function
| M_string -> "string"
| M_ref c -> "ref(" ^ mcontext2s c ^ ")"
| M_revision -> "revision"
+ | M_undef -> "undef"
| M_sub -> "sub"
| M_scalar -> "scalar"
@@ -1057,7 +1059,7 @@ let rec mcontext2s = function
| M_mixed l -> String.concat " | " (List.map mcontext2s l)
let mcontext_is_scalar = function
- | M_int | M_float | M_string | M_ref _ | M_revision
+ | M_int | M_float | M_string | M_ref _ | M_revision | M_undef
| M_scalar | M_array -> true
| _ -> false
@@ -1075,6 +1077,7 @@ let rec mcontext_lower c1 c2 =
| M_ref _, M_scalar | M_ref _, M_list
| M_string, M_string | M_string, M_scalar | M_string, M_list
| M_revision, M_revision | M_revision, M_scalar | M_revision, M_list
+ | M_undef, M_undef | M_undef, M_scalar | M_undef, M_list
| M_scalar, M_scalar | M_scalar, M_list
-> true
diff --git a/perl_checker.src/test/context.t b/perl_checker.src/test/context.t
index 5fd7809..edb0452 100644
--- a/perl_checker.src/test/context.t
+++ b/perl_checker.src/test/context.t
@@ -13,3 +13,5 @@ length @l never use "length @l", it returns the l
'xxx' > 'yyy' you should use a string operator, not the number operator ">"
1 cmp 2 you should use a number operator, not the string operator "cmp" (or replace the number with a string)
+
+$xxx == undef context undef is not compatible with context float
diff --git a/perl_checker.src/types.mli b/perl_checker.src/types.mli
index e10e8f5..bff90ca 100644
--- a/perl_checker.src/types.mli
+++ b/perl_checker.src/types.mli
@@ -17,7 +17,7 @@ type maybe_context =
| M_none
| M_bool
- | M_int | M_float | M_string | M_ref of maybe_context | M_revision | M_sub
+ | M_int | M_float | M_string | M_ref of maybe_context | M_revision | M_sub | M_undef
| M_scalar
| M_tuple of maybe_context list