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

GADTs: Incorrect types inferred in recursive function while modifying code #1829

Open
2BitSalute opened this issue Sep 18, 2024 · 0 comments

Comments

@2BitSalute
Copy link

2BitSalute commented Sep 18, 2024

Sorry this repro is a bit long, but I couldn't reduce it any further. It's something about the presence of all the elements in this example that triggers the incorrect errors, and also the order seems to matter.

The error persists in the file until I restart the language server.

Steps

  1. Start with repro_initial.ml
    • Dune: (libraries core core_unix core_unix.sys_unix)
  2. Change line 4 from | Step : ('a -> 'b)... to | Step : string * ('a -> 'b)...
  3. Fix up the rest of the code: ( @> ), exec_with_profile, then sum_file_sizes

Expected

No errros

Actual

At line 28 (the recursive base case of exec_with_profile), 2 errors appear.

Empty

Empty should be of type ('a, 'a) pipeline.

However, it is identified as (string list, string list) pipeline, and it is underlined with this error:

This pattern matches values of type (string list, string list) pipeline
but a pattern was expected which matches values of type
(input, output) pipeline
The type constructor output would escape its scope
(ocamllsp)

input

input should be of the locally abstract type input, but it seems to be string list, if I'm reading the error correctly.

This is the error:

This expression has type input = string list
but an expression was expected of type output
This instance of string list is ambiguous:
it would escape the scope of its equation
(ocamllsp)

I trimmed the recording just to where the error first appears, which is when I still have a few things to fix up, but even after the code compiles, the 2 errors persist.

ocamllsp_recording_480p_trimmed.mov
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

No branches or pull requests

1 participant