Skip to content

Alert floating attributes in mli are ignored #6820

@david-maison-TrustInSoft

Description

Reproduction

With the following files:

$ cat dune
(executable
 (name bar)
 (flags (-alert +all))
 (modules foo bar))

$ cat dune-project
(lang dune 2.7)

$ cat bar.ml
let () = print_endline Foo.x

$ cat foo.ml
let x = "Hello"

$ cat foo.mli
[@@@alert unsafe "Reason: it's not safe."]

val x : string

Run dune build.

Expected Behavior

dune build should exit 0 (or 1 if alerts are fatal) with an error message as we can observe with the following command line:

$ ocamlc -c -alert +all foo.mli foo.ml bar.ml
File "bar.ml", line 1, characters 23-28:
1 | let () = print_endline Foo.x
                           ^^^^^
Alert unsafe: module Foo
Reason: it's not safe.

Actual Behavior

dune build exits 0 without printing anything.

Specifications

  • Version of dune (output of dune --version): 3.6.1
  • Version of ocaml (output of ocamlc --version): 4.14.0
  • Operating system (distribution and version): Ubuntu 22.04.1 LTS

Additional information

If the attribute is attached to the val x declaration, it works correctly. A workaround would be to remove the floating attribute and add an item attribute for each declaration.

Same problem with deprecated or ocaml.deprecated attributes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions