Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
small testsuite for shadowing warnings
- Loading branch information
Showing
2 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
let ignore _ = () | ||
|
||
module Pervasives = struct | ||
(* the evil shadower *) | ||
let compare x y = (x, y) | ||
let (<=) x y = (x, y) | ||
let (mod) x y = (x, y) | ||
let (.()) x y = (x, y) | ||
let x = () | ||
end | ||
|
||
[@@@ocaml.warning "+A"] | ||
|
||
(* this should not warn: shadowed identifier is not used *) | ||
let alpha compare = | ||
ignore compare; | ||
let open Pervasives in | ||
x | ||
|
||
let infix (<=) = | ||
ignore (<=); | ||
let open Pervasives in | ||
x | ||
|
||
let false_infix (mod) = | ||
ignore (mod); | ||
let open Pervasives in | ||
x | ||
|
||
let access (.()) = | ||
ignore (.()); | ||
let open Pervasives in | ||
x | ||
|
||
let () = | ||
ignore alpha; | ||
ignore infix; | ||
ignore false_infix; | ||
ignore access; | ||
() | ||
|
||
(* this should raise 44 (the old warning) *) | ||
let alpha compare = | ||
ignore compare; | ||
let open Pervasives in | ||
compare | ||
|
||
(* this should raise 44 (the old warning) *) | ||
let infix (<=) = | ||
ignore (<=); | ||
let open Pervasives in | ||
(<=) | ||
|
||
let false_infix (mod) = | ||
ignore (mod); | ||
let open Pervasives in | ||
(mod) | ||
|
||
let false_infix2 (mod) a b = | ||
ignore (mod); | ||
let open Pervasives in | ||
a mod b | ||
|
||
let access (.()) = | ||
ignore (.()); | ||
let open Pervasives in | ||
(.()) | ||
|
||
let access2 (.()) a b = | ||
ignore (.()); | ||
let open Pervasives in | ||
a.(b) | ||
|
||
let () = | ||
ignore alpha; | ||
ignore infix; | ||
ignore false_infix; | ||
ignore false_infix2; | ||
ignore access; | ||
ignore access2; | ||
() | ||
|
||
[@@@ocaml.warning "+A-44"] | ||
|
||
(* this should raise 52 (the new warning) *) | ||
let alpha compare = | ||
ignore compare; | ||
let open Pervasives in | ||
compare | ||
|
||
(* this should raise 53 (the new warning) *) | ||
let infix (<=) = | ||
ignore (<=); | ||
let open Pervasives in | ||
(<=) | ||
|
||
let false_infix (mod) = | ||
ignore (mod); | ||
let open Pervasives in | ||
(mod) | ||
|
||
let false_infix2 (mod) a b = | ||
ignore (mod); | ||
let open Pervasives in | ||
a mod b | ||
|
||
let access (.()) = | ||
ignore (.()); | ||
let open Pervasives in | ||
(.()) | ||
|
||
let access2 (.()) a b = | ||
ignore (.()); | ||
let open Pervasives in | ||
a.(b) | ||
|
||
|
||
let () = | ||
ignore alpha; | ||
ignore infix; | ||
ignore false_infix; | ||
ignore false_infix2; | ||
ignore access; | ||
ignore access2; | ||
() | ||
|
||
[@@@ocaml.warning "-A"] | ||
|
||
(* this shouldn't raise anything *) | ||
|
||
let alpha compare = | ||
ignore compare; | ||
let open Pervasives in | ||
compare | ||
|
||
let infix (<=) = | ||
ignore (<=); | ||
let open Pervasives in | ||
(<=) | ||
|
||
let false_infix (mod) = | ||
ignore (mod); | ||
let open Pervasives in | ||
(mod) | ||
|
||
let false_infix (mod) a b = | ||
ignore (mod); | ||
let open Pervasives in | ||
a mod b | ||
|
||
let access (.()) = | ||
ignore (.()); | ||
let open Pervasives in | ||
(.()) | ||
|
||
let access2 (.()) a b = | ||
ignore (.()); | ||
let open Pervasives in | ||
a.(b) | ||
|
||
let () = | ||
ignore alpha; | ||
ignore infix; | ||
ignore false_infix; | ||
ignore false_infix2; | ||
ignore access; | ||
ignore access2; | ||
() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
File "w44.ml", line 45, characters 2-34: | ||
Warning 44: this open statement shadows the value identifier compare (which is later used) | ||
File "w44.ml", line 51, characters 2-31: | ||
Warning 44: this open statement shadows the value identifier <= (which is later used) | ||
File "w44.ml", line 56, characters 2-32: | ||
Warning 44: this open statement shadows the value identifier mod (which is later used) | ||
File "w44.ml", line 61, characters 2-34: | ||
Warning 44: this open statement shadows the value identifier mod (which is later used) | ||
File "w44.ml", line 66, characters 2-32: | ||
Warning 44: this open statement shadows the value identifier .() (which is later used) | ||
File "w44.ml", line 71, characters 2-32: | ||
Warning 44: this open statement shadows the value identifier .() (which is later used) | ||
File "w44.ml", line 88, characters 2-34: | ||
Warning 52: this open statement shadows the value identifier compare (which is later used) | ||
File "w44.ml", line 94, characters 2-31: | ||
Warning 53: this open statement shadows the operator ( <= ) (which is later used) | ||
File "w44.ml", line 99, characters 2-32: | ||
Warning 53: this open statement shadows the operator ( mod ) (which is later used) | ||
File "w44.ml", line 104, characters 2-34: | ||
Warning 53: this open statement shadows the operator ( mod ) (which is later used) | ||
File "w44.ml", line 109, characters 2-32: | ||
Warning 53: this open statement shadows the operator ( .() ) (which is later used) | ||
File "w44.ml", line 114, characters 2-32: | ||
Warning 53: this open statement shadows the operator ( .() ) (which is later used) |