summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl_checker.src/parser_helper.ml9
-rw-r--r--perl_checker.src/parser_helper.mli8
2 files changed, 11 insertions, 6 deletions
diff --git a/perl_checker.src/parser_helper.ml b/perl_checker.src/parser_helper.ml
index c0d27f1..731b78f 100644
--- a/perl_checker.src/parser_helper.ml
+++ b/perl_checker.src/parser_helper.ml
@@ -496,10 +496,9 @@ let check_hash_subscript esp =
| List [Raw_string(s, _)] when can_be_raw_string s -> warn [Warn_suggest_simpler] esp.pos (sprintf "{'%s'} can be written {%s}" s s)
| _ -> ()
-let check_arrow_needed esp1 esp2 =
- match esp1.any.expr with
+let check_arrow_needed arrow = function
| Deref_with(I_array, I_scalar, List [List [Call _]], _) -> () (* "->" needed for (f())[0]->{XX} *)
- | Deref_with _ -> warn [Warn_suggest_simpler] esp2.pos "the arrow \"->\" is unneeded"
+ | Deref_with _ -> warn [Warn_suggest_simpler] arrow.pos "the arrow \"->\" is unneeded"
| _ -> ()
let check_scalar_subscripted esp =
@@ -672,6 +671,10 @@ let to_Deref_with(from_context, to_context, ref_, para) =
if is_not_a_scalar ref_ then warn_rule [] "bad deref";
Deref_with(from_context, to_context, ref_, para)
+let to_Deref_with_arrow arrow (from_context, to_context, ref_, para) =
+ if from_context != I_func then check_arrow_needed arrow ref_ ;
+ to_Deref_with(from_context, to_context, ref_, para)
+
let lines_to_Block esp_lines esp_BRACKET_END =
check_block_lines esp_lines esp_BRACKET_END;
Block (fst esp_lines.any)
diff --git a/perl_checker.src/parser_helper.mli b/perl_checker.src/parser_helper.mli
index 6485011..0708792 100644
--- a/perl_checker.src/parser_helper.mli
+++ b/perl_checker.src/parser_helper.mli
@@ -103,9 +103,7 @@ val check_parenthesized_first_argexpr_with_Ident :
Types.fromparser list Types.prio_anyexpr Types.any_spaces_pos -> unit
val check_hash_subscript :
Types.fromparser Types.prio_anyexpr Types.any_spaces_pos -> unit
-val check_arrow_needed :
- Types.fromparser Types.prio_anyexpr Types.any_spaces_pos ->
- 'a Types.any_spaces_pos -> unit
+val check_arrow_needed : 'a Types.any_spaces_pos -> Types.fromparser -> unit
val check_scalar_subscripted : Types.fromparser Types.any_spaces_pos -> unit
val negatable_ops : (string * string) list
val check_negatable_expr :
@@ -158,6 +156,10 @@ val to_Method_call :
val to_Deref_with :
Types.context * Types.context * Types.fromparser * Types.fromparser ->
Types.fromparser
+val to_Deref_with_arrow :
+ 'a Types.any_spaces_pos ->
+ Types.context * Types.context * Types.fromparser * Types.fromparser ->
+ Types.fromparser
val lines_to_Block :
(Types.fromparser list * bool) Types.any_spaces_pos ->
'a Types.any_spaces_pos -> Types.fromparser