summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl_checker.src/parser.mly6
-rw-r--r--perl_checker.src/parser_helper.ml4
-rw-r--r--perl_checker.src/types.mli1
3 files changed, 8 insertions, 3 deletions
diff --git a/perl_checker.src/parser.mly b/perl_checker.src/parser.mly
index 9fa0deb..d8855e0 100644
--- a/perl_checker.src/parser.mly
+++ b/perl_checker.src/parser.mly
@@ -230,8 +230,8 @@ term:
| term OR_TIGHT BRACKET expr BRACKET_END {sp_p($2); sp_p($3); sp_p($4); sp_p($5); to_Call_op_ M_scalar P_tight_or "||" [prio_lo P_assign $1; Ref(I_hash, $4.any.expr)] $1 $5}
-| term PATTERN_MATCH PATTERN {sp_n($2); sp_p($3); check_unneeded_var_dollar_ ($1); let pattern = from_PATTERN $3 in check_simple_pattern pattern ; to_Call_op_ M_array P_expr "m//" ($1.any.expr :: pattern) $1 $3}
-| term PATTERN_MATCH_NOT PATTERN {sp_n($2); sp_p($3); check_unneeded_var_dollar_not($1); let pattern = from_PATTERN $3 in check_simple_pattern pattern ; to_Call_op_ M_int P_expr "!m//" ($1.any.expr :: pattern) $1 $3}
+| term PATTERN_MATCH PATTERN {sp_n($2); sp_p($3); check_unneeded_var_dollar_ ($1); mcontext_check M_string $1; let pattern = from_PATTERN $3 in check_simple_pattern pattern ; to_Call_op_ M_array P_expr "m//" ($1.any.expr :: pattern) $1 $3}
+| term PATTERN_MATCH_NOT PATTERN {sp_n($2); sp_p($3); check_unneeded_var_dollar_not($1); mcontext_check M_string $1; let pattern = from_PATTERN $3 in check_simple_pattern pattern ; to_Call_op_ M_int P_expr "!m//" ($1.any.expr :: pattern) $1 $3}
| term PATTERN_MATCH PATTERN_SUBST {sp_n($2); sp_p($3); check_unneeded_var_dollar_s ($1); to_Call_op_ (M_mixed[M_none; M_int]) P_expr "s///" ($1.any.expr :: from_PATTERN_SUBST $3) $1 $3}
| term PATTERN_MATCH_NOT PATTERN_SUBST {die_with_rawpos $2.pos "use =~ instead of !~ and negate the return value"}
@@ -263,7 +263,7 @@ term:
to_Call_op_ (mcontext_unop M_float $2) P_tight "- unary" [$2.any.expr] $1 $2
| _ -> die_rule "syntax error"
}
-| TIGHT_NOT term {check_negatable_expr $2; to_Call_op_ (mcontext_unop M_scalar $2) P_tight "not" [$2.any.expr] $1 $2}
+| TIGHT_NOT term {check_negatable_expr $2; mcontext_check M_scalar $2; to_Call_op_ M_bool P_tight "not" [$2.any.expr] $1 $2}
| BIT_NEG term {to_Call_op_ (mcontext_unop M_int $2) P_expr "~" [$2.any.expr] $1 $2}
| INCR term {sp_0($2); mcontext_check M_int $2; to_Call_op_ (M_mixed [M_int ; M_none]) P_tight "++" [$2.any.expr] $1 $2}
| DECR term {sp_0($2); mcontext_check M_int $2; to_Call_op_ (M_mixed [M_int ; M_none]) P_tight "--" [$2.any.expr] $1 $2}
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index 5a55e03..74fad21 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -949,6 +949,8 @@ let from_PATTERN_SUBST parse { any = (s1, s2, opts) ; pos = pos } =
let rec mcontext2s = function
| M_none -> "()"
+ | M_bool -> "bool"
+
| M_int -> "int"
| M_float -> "float"
| M_string -> "string"
@@ -977,6 +979,8 @@ let rec mcontext_lower c1 c2 =
| M_array, M_array | M_array, M_int | M_array, M_float | M_array, M_scalar | M_array, M_list
| M_hash, M_hash | M_hash, M_scalar | M_hash, M_list
+ | M_bool, M_bool | M_bool, M_scalar | M_bool, M_list
+
| M_int, M_int | M_int, M_float | M_int, M_string | M_int, M_scalar | M_int, M_list
| M_float, M_float | M_float, M_string | M_float, M_scalar | M_float, M_list
| M_ref _, M_scalar | M_ref _, M_list
diff --git a/perl_checker.src/types.mli b/perl_checker.src/types.mli
index 19f8d9d..812392d 100644
--- a/perl_checker.src/types.mli
+++ b/perl_checker.src/types.mli
@@ -16,6 +16,7 @@ type context = I_scalar | I_hash | I_array | I_func | I_raw | I_star
type maybe_context =
| M_none
+ | M_bool
| M_int | M_float | M_string | M_ref of maybe_context | M_revision | M_sub
| M_scalar