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

Extensible records aren't typechecked properly #678

Closed
RoganMurley opened this issue Jan 8, 2022 · 0 comments · Fixed by #955
Closed

Extensible records aren't typechecked properly #678

RoganMurley opened this issue Jan 8, 2022 · 0 comments · Fixed by #955
Assignees
Labels
type inference Related to type inference
Milestone

Comments

@RoganMurley
Copy link

Extensible records aren't typechecked properly. The language server throws errors where the the elm compiler does not, and vice versa.

I found two different kinds of errors do let me know if you'd like me to split into multiple issues.

Expected Behavior

Unbound type variables

The following two examples should error because unbound type variables are used:

type Example = Example { a | foo : Float }
type alias Example = { a | foo : Float }

An error similar to the elm compiler one should be thrown:

The `Example` type alias uses an unbound type variable `a` in its definition:

8| type alias Example = { a | foo : Float }
                          ^
You probably need to change the declaration to something like this:

    type alias Example a = ...

Why? Well, imagine one `Example` where `a` is an Int and another where it is a
Bool. When we explicitly list the type variables, the type checker can see that
they are actually different types.

Incorrect type inference

This shouldn't error as elm compiler typechecks it fine:

type Example a = Example { a | foo : Float }

example : Example {}
example = Example { foo = 0 }

Current Behavior

Unbound type variables

The following two examples throw no errors, despite use of unbound type variables.

type Example = Example { a | foo : Float }
type alias Example = { a | foo : Float }

Incorrect type inference

The following example...

type Example a = Example { a | foo : Float }

example : Example {}
example = Example { foo = 0 }

...shows the following error...

Type mismatch error.
Expected: `Example {  }`
Found: `Example { foo : Float }`Elm

...when it should typecheck fine.

Context

I have a project that compiles fine, but when trying to move to using VSCode errors are shown for code that compiles fine. This project is open source, so here is an example file with errors.

Your Environment

  • Version used: 2.4.0
  • Editor used: Elm Plugin for Visual Studio Code
  • Environment name and version : node v12.22.5
  • Operating System and version: Ubuntu 21.10
@jmbockhorst jmbockhorst added the type inference Related to type inference label May 12, 2022
@jmbockhorst jmbockhorst added this to the 2.7 milestone Apr 26, 2023
@jmbockhorst jmbockhorst self-assigned this Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type inference Related to type inference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants