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

Bad long-form error "You can only combine records" #1701

Closed
sjakobi opened this issue Mar 10, 2020 · 0 comments · Fixed by #1702
Closed

Bad long-form error "You can only combine records" #1701

sjakobi opened this issue Mar 10, 2020 · 0 comments · Fixed by #1702
Assignees
Labels
bug error messages Better error reporting

Comments

@sjakobi
Copy link
Collaborator

sjakobi commented Mar 10, 2020

$ echo '{=} // 1' | dhall --explain


Error: You can only combine records

Explanation: You can combine records using the ❰⫽❱ operator, like this:


    ┌───────────────────────────────────────────┐
    │ { foo = 1, bar = "ABC" } ⫽ { baz = True } │
    └───────────────────────────────────────────┘


    ┌─────────────────────────────────────────────┐
    │ λ(r : { foo : Bool }) → r ⫽ { bar = "ABC" } │
    └─────────────────────────────────────────────┘


... but you cannot combine values that are not records.

For example, the following expressions are not valid:


    ┌──────────────────────────────┐
    │ { foo = 1, bar = "ABC" } ⫽ 1 │
    └──────────────────────────────┘
                                 ⇧
                                 Invalid: Not a record


    ┌───────────────────────────────────────────┐
    │ { foo = 1, bar = "ABC" } ⫽ { baz : Bool } │
    └───────────────────────────────────────────┘
                                 ⇧
                                 Invalid: This is a record type and not a record


    ┌───────────────────────────────────────────┐
    │ { foo = 1, bar = "ABC" } ⫽ < baz : Bool > │
    └───────────────────────────────────────────┘
                                 ⇧
                                 Invalid: This is a union type and not a record


You tried to combine the following value:

↳ {=}

... which is not a record, but is actually a:

↳ 1

────────────────────────────────────────────────────────────────────────────────

1│ {=} // 1

(stdin):1:1

This bit seems to have some things mixed up:

You tried to combine the following value:

↳ {=}

... which is not a record, but is actually a:

↳ 1
@sjakobi sjakobi added bug error messages Better error reporting labels Mar 10, 2020
@sjakobi sjakobi self-assigned this Mar 10, 2020
sjakobi added a commit that referenced this issue Mar 10, 2020
For `{=} // 1`, we would previously report:

    You tried to combine the following value:

    ↳ {=}

    ... which is not a record, but is actually a:

    ↳ 1

Now we report:

    You tried to combine the following value:

    ↳ 1

    ... which is not a record, but is actually a:

    ↳ Natural

Fixes #1701.
@mergify mergify bot closed this as completed in #1702 Mar 10, 2020
mergify bot pushed a commit that referenced this issue Mar 10, 2020
For `{=} // 1`, we would previously report:

    You tried to combine the following value:

    ↳ {=}

    ... which is not a record, but is actually a:

    ↳ 1

Now we report:

    You tried to combine the following value:

    ↳ 1

    ... which is not a record, but is actually a:

    ↳ Natural

Fixes #1701.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug error messages Better error reporting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant