Skip to content

Probe name too long: warning instead of error #1352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ocaml/testsuite/tests/warnings/w190.compilers.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
File "w190.ml", line 13, characters 10-130:
13 | [%probe "name_is_too_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" (print_int x)];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 190 [probe-name-too-long]: This probe name is too long: `name_is_too_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo'. Probe names must be at most 100 characters long.
14 changes: 14 additions & 0 deletions ocaml/testsuite/tests/warnings/w190.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(* TEST

flags = "-w +A-70"

* setup-ocamlc.byte-build-env
** ocamlc.byte
compile_only = "true"
*** check-ocamlc.byte-output

*)

let foo x =
[%probe "name_is_too_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo" (print_int x)];
x
8 changes: 1 addition & 7 deletions ocaml/typing/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ type error =
| Invalid_extension_constructor_payload
| Not_an_extension_constructor
| Probe_format
| Probe_name_too_long of string
| Probe_name_format of string
| Probe_name_undefined of string
| Probe_is_enabled_format
Expand Down Expand Up @@ -255,7 +254,7 @@ type recarg =
let probe_name_max_length = 100
let check_probe_name name loc env =
if String.length name > probe_name_max_length then
raise (Error (loc, env, (Probe_name_too_long name)));
Location.prerr_warning loc (Warnings.Probe_name_too_long name);
String.iter (fun c ->
match c with
| 'a'..'z' | 'A'..'Z' | '0'..'9' | '_' -> ()
Expand Down Expand Up @@ -8029,11 +8028,6 @@ let report_error ~loc env = function
| Not_an_extension_constructor ->
Location.errorf ~loc
"This constructor is not an extension constructor."
| Probe_name_too_long name ->
Location.errorf ~loc
"This probe name is too long: `%s'. \
Probe names must be at most %d characters long."
name probe_name_max_length
| Probe_name_format name ->
Location.errorf ~loc
"Illegal characters in probe name `%s'. \
Expand Down
1 change: 0 additions & 1 deletion ocaml/typing/typecore.mli
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ type error =
| Invalid_extension_constructor_payload
| Not_an_extension_constructor
| Probe_format
| Probe_name_too_long of string
| Probe_name_format of string
| Probe_name_undefined of string
(* CR-soon mshinwell: Use an inlined record *)
Expand Down
9 changes: 9 additions & 0 deletions ocaml/utils/warnings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ type t =
| Missing_mli (* 70 *)
| Unused_tmc_attribute (* 71 *)
| Tmc_breaks_tailcall (* 72 *)
| Probe_name_too_long of string (* 190 *)
| Unchecked_property_attribute of string (* 199 *)
;;

Expand Down Expand Up @@ -190,6 +191,7 @@ let number = function
| Missing_mli -> 70
| Unused_tmc_attribute -> 71
| Tmc_breaks_tailcall -> 72
| Probe_name_too_long _ -> 190
| Unchecked_property_attribute _ -> 199
;;

Expand Down Expand Up @@ -448,6 +450,9 @@ let descriptions = [
names = ["tmc-breaks-tailcall"];
description = "A tail call is turned into a non-tail call \
by the @tail_mod_cons transformation." };
{ number = 190;
names = ["probe-name-too-long"];
description = "Probe name must be at most 100 characters long." };
{ number = 199;
names = ["unchecked-property-attribute"];
description = "A property of a function that was \
Expand Down Expand Up @@ -1051,6 +1056,10 @@ let message = function
Please either mark the called function with the [@tail_mod_cons]\n\
attribute, or mark this call with the [@tailcall false] attribute\n\
to make its non-tailness explicit."
| Probe_name_too_long name ->
Printf.sprintf
"This probe name is too long: `%s'. \
Probe names must be at most 100 characters long." name
| Unchecked_property_attribute property ->
Printf.sprintf "the %S attribute cannot be checked.\n\
The function it is attached to was optimized away. \n\
Expand Down
1 change: 1 addition & 0 deletions ocaml/utils/warnings.mli
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ type t =
| Unused_tmc_attribute (* 71 *)
| Tmc_breaks_tailcall (* 72 *)
(* Flambda_backend specific warnings: numbers should go down from 199 *)
| Probe_name_too_long of string (* 190 *)
| Unchecked_property_attribute of string (* 199 *)
;;

Expand Down
5 changes: 5 additions & 0 deletions tests/backend/probes/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(rule
(alias runtest)
(enabled_if (= %{context_name} "main"))
(deps t1.ml)
(action (run %{bin:ocamlopt.opt} %{deps} -warn-error "+190" -c)))
3 changes: 3 additions & 0 deletions tests/backend/probes/t1.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
let foo x =
[%probe "name" (print_int x)];
x