Skip to content

PPX: reconsider disabling warning 20 in all functions #1165

@jchavarri

Description

@jchavarri

In #915, the silencing of warning 20 was moved to all function applications (regardless if the function is defined with mel.raw or not).

I understand it's impossible to detect this kind of situation at PPX time. But I wonder if the silencing should be removed from the PPX, and instead document in mel.raw docs that these functions need to be explicitly annotated? E.g. if the ppx was modified to not add the attribute, this test would trigger the following results:

Usage of mel.raw can trigger warning 20 ([ignored-extra-argument])

  $ . ./setup.sh
  $ cat > dune-project <<EOF
  > (lang dune 3.8)
  > (using melange 0.1)
  > EOF
  $ cat > dune << EOF
  > (melange.emit
  >  (target out)
  >  (emit_stdlib false)
  >  (preprocess (pps melange.ppx)))
  > EOF

  $ cat > foo.ml <<EOF
  > let addOne = [%mel.raw {|
  >   function (a) {
  >     return a + 1;
  >   }
  > |}]
  > let x = addOne 2
  > EOF

  $ dune build @melange
  File "foo.ml", line 6, characters 15-16:
  6 | let x = addOne 2
                     ^
  Error (warning 20 [ignored-extra-argument]): this argument will not be used by the function.
  [1]

Annotating the function (which should always be the case, for safety) makes the
warning go away

  $ cat > foo.ml <<EOF
  > let addOne: int -> int = [%mel.raw {|
  >   function (a) {
  >     return a + 1;
  >   }
  > |}]
  > let x = addOne 2
  > EOF

  $ dune build @melange

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