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

test: repro #840 #842

Merged
merged 1 commit into from
Jul 23, 2024
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
76 changes: 76 additions & 0 deletions ppx/test/hover.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Test some locations in reason-react components, reproduces #840

$ cat >dune-project <<EOF
> (lang dune 3.13)
> (using melange 0.1)
> EOF

$ cat >dune <<EOF
> (melange.emit
> (alias foo)
> (target foo)
> (libraries reason-react)
> (emit_stdlib false)
> (preprocess
> (pps melange.ppx reason-react-ppx)))
> EOF

$ cat >component.ml <<EOF
> let[@react.component] make ~foo ~bar =
> (div
> ~children:[ React.string foo; bar |> string_of_int |> React.string ]
> () [@JSX])
> EOF
$ dune build @foo

Let's test hovering over parts of the component

`React.string`:

$ ocamlmerlin single type-enclosing -position 3:25 -verbosity 0 \
> -filename component.ml < component.ml | jq '.value'
[
{
"start": {
"line": 3,
"col": 17
},
"end": {
"line": 3,
"col": 29
},
"type": "string -> React.element",
"tail": "no"
},
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 4,
"col": 15
},
"type": "< bar : int; foo : string > Js.t -> React.element",
"tail": "no"
}
]

The `foo` variable inside the component body

$ ocamlmerlin single type-enclosing -position 3:31 -verbosity 0 \
> -filename component.ml < component.ml | jq '.value'
[
{
"start": {
"line": 1,
"col": 0
},
"end": {
"line": 4,
"col": 15
},
"type": "< bar : int; foo : string > Js.t -> React.element",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this reproduces the issue @feihong reported: this type should be string, but instead it's the entire function type.

"tail": "no"
}
]
Loading