Skip to content
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

add test for mel.uncurry #875

Merged
merged 2 commits into from
Dec 4, 2023
Merged
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
58 changes: 58 additions & 0 deletions test/blackbox-tests/mel-uncurry-nesting.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Test the attribute @mel.uncurry at different level of nesting

$ . ./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

Normal uncurry at first level works fine

$ cat > x.ml <<EOF
> external foo : ((unit -> unit)[@mel.uncurry]) -> unit
> = "foo"
> EOF

$ dune build @melange

Using `mel.uncurry` at 2nd level of callbacks raises some alerts

$ cat > x.ml <<EOF
> external foo :
> (((unit -> unit)[@mel.uncurry]) -> (unit -> unit[@mel.uncurry])) -> unit
> = "foo"
> EOF
$ dune build @melange
File "x.ml", line 2, characters 20-31:
2 | (((unit -> unit)[@mel.uncurry]) -> (unit -> unit[@mel.uncurry])) -> unit
^^^^^^^^^^^
Alert unused: Unused attribute [@mel.uncurry]
This means such annotation is not annotated properly.
For example, some annotations are only meaningful in externals


File "x.ml", line 2, characters 52-63:
2 | (((unit -> unit)[@mel.uncurry]) -> (unit -> unit[@mel.uncurry])) -> unit
^^^^^^^^^^^
Alert unused: Unused attribute [@mel.uncurry]
This means such annotation is not annotated properly.
For example, some annotations are only meaningful in externals



In the case of uncurry nesting, we have to resort to the `[@u]` attribute

$ cat > x.ml <<EOF
> external foo : (((unit -> unit)[@u]) -> unit) -> unit = "foo"
> let () = foo (fun f -> f () [@u])
> EOF
$ dune build @melange