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

Fix #143 #144

Merged
merged 6 commits into from
Jan 5, 2019
Merged

Fix #143 #144

merged 6 commits into from
Jan 5, 2019

Conversation

travisbrown
Copy link
Contributor

This is a funny one. The problem is that the new error message stuff from #129 calls at(i, j) with out-of-bounds arguments on AsyncParser, which throws an AsyncException instead of a ParseException, which means the absorb call isn't treated as a failure.

My feeling is that we're going to keep seeing problems introduced by #129 for a while, starting with #142, which I'm hoping to get to next.

r? @BenFradet @non

@BenFradet
Copy link

Nice, thanks for digging into it!

@travisbrown
Copy link
Contributor Author

Note that this means that Parser.parseFromString("}x")(NullFacade) fails with the following:

ParseException: expected json value got '}...' (line 1, column 1)

…instead of the current:

ParseException: expected json value got '}x' (line 1, column 1)

…which seems reasonable to me, but we could alternatively fix this by making sure die doesn't leak AsyncExceptions.

@travisbrown travisbrown mentioned this pull request Jan 4, 2019
2 tasks
@rossabaker
Copy link
Member

Some more things that return Right on absorb even though they're already bad:

  • fälse
  • nüll
  • trüe
  • 0x
  • 0.x
  • 0ex
  • [1; 2]
  • {"a"; 1}
  • {1: 2}
  • I'm pretty sure a Unicode one, but I couldn't make it die in the right place

This fix works, but maybe it's worth exploring that alternative idea with the leaking AsyncExceptions to handle more of these.

@travisbrown
Copy link
Contributor Author

travisbrown commented Jan 4, 2019

@rossabaker Nice. And agreed. I'm happy to take a stab at it but it might be a couple of days, so if someone else wants to deal with it sooner I'm happy to review.

@travisbrown
Copy link
Contributor Author

Just pushed a fix that makes sure die doesn't throw AsyncException.

Copy link
Member

@rossabaker rossabaker left a comment

Choose a reason for hiding this comment

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

I like it. Add a @tailrec if both you and scalac find it agreeable, but 👍 either way.

if (j <= i) "" else {
try at(i, j) catch {
case _: Exception =>
safeAt(i, j - 1)
Copy link
Member

Choose a reason for hiding this comment

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

j-i is at most ErrorContext (which is 6), right? Just wondering about catching and throwing absurd numbers of exceptions as it walks back, but I won't lose sleep over up to 6. And I think it's @tailrec, though I didn't ask scalac.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In theory you could pass some ridiculously large context to die, but it's protected, so I'm not too worried about that. Also except in the (kind of weird) AsyncParser usage the at call in safeAt will never throw exceptions at all, since atEof has been checked.

(It is @tailrec, by the way, so I went ahead and added it.)

@travisbrown travisbrown merged commit 6388d6f into master Jan 5, 2019
@larsrh larsrh deleted the fix/143 branch June 8, 2019 08:15
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.

3 participants