Skip to content

Allow errors to carry multiple positions#3255

Merged
garyb merged 1 commit intopurescript:masterfrom
garyb:multi-position-errors
Mar 10, 2018
Merged

Allow errors to carry multiple positions#3255
garyb merged 1 commit intopurescript:masterfrom
garyb:multi-position-errors

Conversation

@garyb
Copy link
Copy Markdown
Member

@garyb garyb commented Feb 25, 2018

As discussed in #3208 (comment)

I guess maybe the approach here is less good than exactly what I suggested in there, as it will break the JSON error format, whereas that would be backwards compatible?

@kritzcreek
Copy link
Copy Markdown
Member

I'd prefer

{
position :: (Maybe) ErrorPosition,
additionalPositions :: [ErrorPosition]
...
}

for the JSON format. For one we should get rid of the Maybe in there once we've fixed all the error messages without spans. I'd like to use a datatype isomorphic to NEL to collect the spans, but with different names for the operations. Having cons overwrite the position that will be presented to the User is a little unintuitive. I'd rather have an explicit setPresentedSpan which pushes the current presented one into the tail (cons), and an operation addSpan which pushes directly into the tail.

@garyb
Copy link
Copy Markdown
Member Author

garyb commented Feb 26, 2018

I'd like to use a datatype isomorphic to NEL to collect the spans, but with different names for the operations. Having cons overwrite the position that will be presented to the User is a little unintuitive. I'd rather have an explicit setPresentedSpan which pushes the current presented one into the tail (cons), and an operation addSpan which pushes directly into the tail.

We can do that, but I'm not sure it's necessary really? We're not going to be modifying positions after we've created the error. The fact we currently decorate errors with positions after the fact sometimes is just because we haven't finished the work to require it in the error constructor yet.

@garyb
Copy link
Copy Markdown
Member Author

garyb commented Feb 26, 2018

(Also the choice of position to show is entirely arbitrary, since the error happens everywhere equally)

@kritzcreek
Copy link
Copy Markdown
Member

Yeah, I don't feel strongly about the NEL wrapper at all, but I do think we shouldn't break the error format here, since the thing we want to communicate is still the always existing primary error.

Copy link
Copy Markdown
Member

@kritzcreek kritzcreek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see a non-breaking change to the error format here

@garyb garyb force-pushed the multi-position-errors branch from 8e60ef9 to 1565e55 Compare March 10, 2018 17:21
@garyb
Copy link
Copy Markdown
Member Author

garyb commented Mar 10, 2018

Updated to preserve the original error format, adding an allSpans field that will carry all available position info. I could have popped the head out of there, but figured maybe providing all the spans in the same format might be more convenient for tooling to deal with when it's updated to accommodate multi-position errors.

@garyb garyb merged commit 3171a77 into purescript:master Mar 10, 2018
@garyb garyb deleted the multi-position-errors branch March 10, 2018 20:01
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 this pull request may close these issues.

2 participants