Stream: ideas

Topic: diffs in error messages


view this post on Zulip Ashley Davis (Jul 08 2024 at 22:14):

@Richard Feldman I was thinking an error message like from Jest or Git diff would be good. Something that shows you color coded differences in expected vs actual.

view this post on Zulip Richard Feldman (Jul 08 2024 at 22:17):

hm, that could result in very long error messages for big types

view this post on Zulip Richard Feldman (Jul 08 2024 at 22:17):

the idea behind omitting things that are the same in both is to try to make the error messages shorter

view this post on Zulip Ashley Davis (Jul 08 2024 at 22:19):

I think when you get a diff from Jest and Git diff it also omits everything that is the same. It only shows you what has been added, removed or changed.

view this post on Zulip Ian McLerran (Jul 08 2024 at 22:23):

Something like this @Ashley Davis ?

There is a problem with the record type:

    { row : {
+       height : Num *,
+       offsetY : Num *,
-       galleryWidth : Int U32,
-       removedItems : List {},
-       targetRowHeight : Int U32,
+       width: Int U64 # added type mismatch for example
-       width: Int U32
     }, … }

view this post on Zulip Ashley Davis (Jul 08 2024 at 22:23):

That would be awesome!

view this post on Zulip Ashley Davis (Jul 08 2024 at 22:23):

It's so clear exactly what's wrong.

view this post on Zulip Richard Feldman (Jul 08 2024 at 22:24):

@Ian McLerran that looks very nice in terms of the diff itself, but what would the complete error message say? :thinking:

view this post on Zulip Ian McLerran (Jul 08 2024 at 22:26):

How about:

── TYPE MISMATCH in Layout.roc ─────────────────────────────────────────────────

This 2nd argument to == has an unexpected type:

71│>      out == {
72│>          row: {
73│>              items: currentRowItems,
74│>              offsetY: 0,
75│>              height: 21,
76│>              currentRowItems: [],
77│>              width: 12u64,
78│>              headings
79│>          },
80│>          removedItems,
81│>          remainingItems: []
82│>      }
The record type has the following mismatches:

    { row : {
+       height : Num *,
+       offsetY : Num *,
-       galleryWidth : Int U32,
-       removedItems : List {},
-       targetRowHeight : Int U32,
+       width: Int U64 # added type mismatch for example
-       width: Int U32
     }, … }

Tip: Try adding the fields marked with a minus, and removing the fields marked with a plus.
If a field appears with both plus and minus, check that the types match.

view this post on Zulip Richard Feldman (Jul 08 2024 at 22:45):

how about this wording?

── TYPE MISMATCH in Layout.roc ─────────────────────────────────────────────────

This 2nd argument to == has an unexpected type:

71│>      out == {
72│>          row: {
73│>              items: currentRowItems,
74│>              offsetY: 0,
75│>              height: 21,
76│>              currentRowItems: [],
77│>              width: 12u64,
78│>              headings
79│>          },
80│>          removedItems,
81│>          remainingItems: []
82│>      }
The provided record has these differences compared to the expected one:

    { row : {
+       height : Num *,
+       offsetY : Num *,
-       galleryWidth : Int U32,
-       removedItems : List {},
-       targetRowHeight : Int U32,
+       width: Int U64
-       width: Int U32
     }, … }

view this post on Zulip Ian McLerran (Jul 08 2024 at 22:46):

I like that. That makes it clear without the tip how to associate the + / - with the expected type.

view this post on Zulip Kiryl Dziamura (Jul 08 2024 at 23:24):

I’d only inverse the diff to suggest to the user how to change the received type to make it expected. I mean, I feel it should be a patch to apply to received type rather than diff with the expected one.
Green lines for me look as something good and red are bad. So I’d expected red lines mean something redundant and green lines are something to be added

view this post on Zulip Richard Feldman (Jul 08 2024 at 23:42):

how about this?

── TYPE MISMATCH in Layout.roc ─────────────────────────────────────────────────

This 2nd argument to == has an unexpected type:

71│>      out == {
72│>          row: {
73│>              items: currentRowItems,
74│>              offsetY: 0,
75│>              height: 21,
76│>              currentRowItems: [],
77│>              width: 12u64,
78│>              headings
79│>          },
80│>          removedItems,
81│>          remainingItems: []
82│>      }
Compared to what I got, here's what I expected:

    { row : {
-       height : Num *,
-       offsetY : Num *,
+       galleryWidth : Int U32,
+       removedItems : List {},
+       targetRowHeight : Int U32,
-       width: Int U64
+       width: Int U32
     }, … }

view this post on Zulip Luke Boswell (Jul 15 2024 at 23:01):

https://github.com/roc-lang/roc/issues/6906

view this post on Zulip Luke Boswell (Jul 15 2024 at 23:01):

Issue raised to track this


Last updated: Jun 16 2026 at 16:19 UTC