-
Notifications
You must be signed in to change notification settings - Fork 34
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 JSON array/object parsers not absorbing child parser errors #1132
🐛 Fix JSON array/object parsers not absorbing child parser errors #1132
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to rebase but besides that, this looks great 👍
370c273
to
74a6855
Compare
5bffcff
to
41b5c8b
Compare
- covers generic cases, not the bug yet
- they aren't outputting errors as they should - for invalid char escape (`\z`) - for invalid unicode escape (`\u1z34`)
- giving `entry` as the `value` parser made it dump errors early (to a dummy `ctx`), before we absorbed them to a parent parser
- covers generic cases, not the bug yet - same as the array stuff earlier...
- only not working when the error is in the `value`; the `key` is fine - this makes sense when you see that `key`/`value` use different parsers
41b5c8b
to
f3258fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some changes in order to make the json entry
parser not take a boolean. Instead the error dumping is now handled by a separate wrapper, to make the intent more clear in the JSON initialize function and also so we don't accidentally dump errors in the future.
Summary
these parsers were not absorbing their child parser's errors due to them calling the JSON
entry
parser (json(dumpErrors = true)
)with
dumpErrors = true
, the child parsers would dump errors into a temporary context that wasn't actually then sent to the language serverhttps://github.com/TheAfroOfDoom/Spyglass/blob/b6ecdcad78be7a44ef564afdfc9c51daedf38de8/packages/json/src/parser/entry.ts#L40-L42
fix is to not use the
entry
parser and instead usejson(dumpErrors = false)
so the errors from child parsers are absorbed later by the parent parsers and ultimately outputted to the language serverhttps://github.com/TheAfroOfDoom/Spyglass/blob/b6ecdcad78be7a44ef564afdfc9c51daedf38de8/packages/core/src/parser/util.ts#L67-L70
the JSON
array
andobject
parsers were the only two places i found that were incorrectly using theentry
parserScreenshots
JSON
array
parserJSON
object
parserBlockers
this PR likely should wait until #1127 is merged since that PR fixes a related bug(the branch is currently rebased off of #1127, so those commits will show up here)#1127 has been merged, so no more blockers 😄