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

Pipe completion unknown/type parameter return types #662

Merged
merged 15 commits into from
Dec 22, 2022

Conversation

zth
Copy link
Collaborator

@zth zth commented Dec 21, 2022

This fixes pipe completion for functions returning a type not known until the code has compiled. Array.reduce being an example, which has the signature ('a, ('a, 'b) => 'a) => 'a. It returns 'a but we don't know what 'a is unless it has compiled.

This makes it so that this now completes as int (after saving):

let _ = [123]->Belt.Array.reduce(0, (acc, curr) => acc + curr)->

Again, note this only has effect after saving (compiling so that the type parameter is instantiated). But it at least enables pipe completion in this scenario, even if it requires saving, which used to not work at all.

@zth zth requested a review from cristianoc December 21, 2022 21:36
Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

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

This seems to be a reasonable compromise.
I think the full solution would involve changing the case of application, which would have to find a way to instantiate function type parameters. That would need to get one's hands dirty with unification though, which is much more complex.

@zth zth requested a review from cristianoc December 22, 2022 12:21
@zth
Copy link
Collaborator Author

zth commented Dec 22, 2022

@cristianoc ready for another look through, I think I fixed all of your points.

@@ -4,13 +4,6 @@

<p align="center">The Official VSCode plugin for ReScript</p>

<p align="center">
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about these changes?

@cristianoc cristianoc merged commit 05a1393 into master Dec 22, 2022
@cristianoc cristianoc deleted the pipe-completion-unknown-return-types branch December 22, 2022 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants