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

Improve diff for un--explained assertion failure #1211

Closed
sjakobi opened this issue Aug 7, 2019 · 1 comment · Fixed by #1213
Closed

Improve diff for un--explained assertion failure #1211

sjakobi opened this issue Aug 7, 2019 · 1 comment · Fixed by #1213

Comments

@sjakobi
Copy link
Collaborator

sjakobi commented Aug 7, 2019

For the code below, dhall --file fibs.dhall reports

Use "dhall --explain" for detailed errors

Error: Assertion failed

- [ … ]
+ [ … ]


16│                assert : fibs 10 ≡ [ 0, 1, 2, 3, 5, 8, 13, 21, 34, 55 ]
17│ 

(stdin):16:16

Only when I turn on --explain, dhall shows me the not-so-large detailed diff:

You tried to assert that this expression:                                       
                                                                                
↳ [ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ]
                                                                                
... is the same as this other expression:                                       
                                                                                
↳ [ 0, 1, 2, 3, 5, 8, 13, 21, 34, 55 ]
                                                                                
... but they differ

(Aside: Instead of reporting the error location as (stdin):16:16, dhall should include the filename fibs.dhall.)

fibs.dhall:

let Prelude =
      https://raw.githubusercontent.com/dhall-lang/dhall-lang/db16cb26a03130f81c4099c3708d6a18db66defc/Prelude/package.dhall

let fibs =
        λ(n : Natural)
      → let Fib = { cur : Natural, next : Natural }
        
        let succ = λ(x : Fib) → { cur = x.next, next = x.cur + x.next }
        
        in  Prelude.List.map
              Fib
              Natural
              (λ(x : Fib) → x.cur)
              (Prelude.List.iterate n Fib succ { cur = 0, next = 1 })

let testFibs = assert : fibs 10 ≡ [ 0, 1, 2, 3, 5, 8, 13, 21, 34, 55 ]

in  fibs
Gabriella439 added a commit that referenced this issue Aug 7, 2019
Fixes #1211

The original implementation of diffing two lists in #450 attempted to add a
special case in the logic for when the list had no common elements.
However, this led to a bug where the two lists would display different
if they were both empty.

lists would never render.

This change fixes that by removing the special case.

The new output for the linked example is:

```
Use "dhall --explain" for detailed errors

Error: Assertion failed

[ …
, - 1
, …
, + 55
]

16│                assert : fibs 10 ≡ [ 0, 1, 2, 3, 5, 8, 13, 21, 34, 55 ]
17│

(stdin):16:16
```
Gabriella439 added a commit that referenced this issue Aug 7, 2019
Fixes #1211

The original implementation of diffing two lists in #450 attempted to add a
special case in the logic for when the list had no common elements.
However, this led to a bug where the two lists would display different
if they were both empty.

lists would never render.

This change fixes that by removing the special case.

The new output for the linked example is:

```
Use "dhall --explain" for detailed errors

Error: Assertion failed

[ …
, - 1
, …
, + 55
]

16│                assert : fibs 10 ≡ [ 0, 1, 2, 3, 5, 8, 13, 21, 34, 55 ]
17│

(stdin):16:16
```
@Gabriella439
Copy link
Collaborator

Fix is up here: #1213

@mergify mergify bot closed this as completed in #1213 Aug 8, 2019
mergify bot pushed a commit that referenced this issue Aug 8, 2019
Fixes #1211

The original implementation of diffing two lists in #450 attempted to add a
special case in the logic for when the list had no common elements.
However, this led to a bug where the two lists would display different
if they were both empty.

lists would never render.

This change fixes that by removing the special case.

The new output for the linked example is:

```
Use "dhall --explain" for detailed errors

Error: Assertion failed

[ …
, - 1
, …
, + 55
]

16│                assert : fibs 10 ≡ [ 0, 1, 2, 3, 5, 8, 13, 21, 34, 55 ]
17│

(stdin):16:16
```
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 a pull request may close this issue.

2 participants