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

Type inference broken when there are comments between arguments on type definition #945

Closed
jyrodrigues opened this issue Apr 18, 2023 · 2 comments · Fixed by #946
Closed
Milestone

Comments

@jyrodrigues
Copy link

I'm not 100% sure this issue belongs here (vs. elm-language-client-vscode) but I think it does. Let me know if I should move it there.

SSCCE:

type MyType
    = MyType
        -- First comment
        -- Second comment
        -- Third comment
        Int


someFunction : MyType -> Bool
someFunction mytype =
    case mytype of
        MyType _ ->
            True

image

Expected Behavior

No errors.

Current Behavior

The following error treats the variant MyType as taking 4 arguments when it actually takes only one (and has 3 comments):

This `case` does not have branches for all possibilities.
Missing possibilities include:
  MyType _ _ _ _

Possible Solution

Once the comments are deleted or moved up the error disappears. It seems that comments are tokenized and somewhere interpreted as type arguments.

The weirdest thing though is that if I check the VSCode plugin box Only Update Diagnostics On Save this error disappears.

I've also seen the error disappear when I save the file but sometimes it does not.

Steps to Reproduce (for bugs)

  1. Copy the code to an Elm file;
  2. Edit the file and see the error.

Your Environment

  • Version used: 2.6.0
  • Editor used: VSCode
  • Environment name and version (e.g. node.js 5.4): Node 19.8.1
  • Operating System and version: MacOS 13.2.1
@jmbockhorst
Copy link
Member

Thanks for reporting. I was able to fix it pretty easily.

@jyrodrigues
Copy link
Author

Thank you @jmbockhorst!!

@jmbockhorst jmbockhorst added this to the 2.7 milestone Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants