Skip to content

fix: Forward declare the Option parseHook - #113

Open
heysokam wants to merge 1 commit into
treeform:masterfrom
heysokam:heysokam/option-fix
Open

fix: Forward declare the Option parseHook#113
heysokam wants to merge 1 commit into
treeform:masterfrom
heysokam:heysokam/option-fix

Conversation

@heysokam

@heysokam heysokam commented Aug 28, 2026

Copy link
Copy Markdown

parseHook for Option[T] is defined at src/jsony.nim:494,
but it is missing from the forward declaration block at the top of the file.

When parseObjectInner line 389, binds parseHook for a field of type Option[T], the Option overload is not yet in scope,
overload resolution then selects parseHook*[T: object|ref object] instead, because Option is an object.
The object hook starts with eatChar(s, i, '{'), so parsing any object with an Option field can fail with:

    Expected { but got 0 instead. At offset: N

Declaring the Option hook alongside the others fixes the binding.

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.

1 participant