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

Handle destruct in function arg #10

Merged
merged 7 commits into from
Apr 16, 2024
Merged
Changes from 1 commit
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
52 changes: 52 additions & 0 deletions tests/test-dirs/destruct/destruct-fun.t
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,55 @@ FIXME UPGRADE 5.2: this was working before the upgrade
],
"notifications": []
}

$ cat >fun.ml <<EOF
> type t = { foo: int }
> let f a (b: t) c = something
> EOF

$ $MERLIN single case-analysis -start 2:10 -end 2:10 \
> -filename fun.ml <fun.ml | \
> sed -e 's/, /,/g' | sed -e 's/ *| */|/g' | tr -d '\n' | jq '.'
{
"class": "return",
"value": [
{
"start": {
"line": 2,
"col": 9
},
"end": {
"line": 2,
"col": 10
}
},
"{ foo }"
],
"notifications": []
}

$ cat >fun.ml <<EOF
> type t = Foo
> let f a (b: t) c = something
> EOF

$ $MERLIN single case-analysis -start 2:10 -end 2:10 \
> -filename fun.ml <fun.ml | \
> sed -e 's/, /,/g' | sed -e 's/ *| */|/g' | tr -d '\n' | jq '.'
{
"class": "return",
"value": [
{
"start": {
"line": 2,
"col": 9
},
"end": {
"line": 2,
"col": 10
}
},
"Foo"
],
"notifications": []
}

Choose a reason for hiding this comment

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

It would also be good to have tests with:

  • A type with one constructor where the constructor has fields.
  • A type with one constructor where the constructor has an inline record
  • A gadt with multiple constructors, but where the types allow only one constructor to be well-typed. (This is harder -- a reach goal.)

Copy link
Author

@xvw xvw Apr 10, 2024

Choose a reason for hiding this comment

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

Hi @goldfirere

  • Works fine
  • As the previous version, it generate Ctor _, but currently, the way that pattern are printed seems wrong. For type t = Foo of {..} it produces Foo_. I am currently investigating on that (it was sed in test mistake from my side. Fixed now)
  • With GADT it seems working too

Loading