Skip to content

fix: Forward declare the Option parseHook - #113

Merged
treeform merged 1 commit into
treeform:masterfrom
heysokam:heysokam/option-fix
Oct 28, 2026
Merged

treeform merged 1 commit into
treeform:masterfrom
heysokam:heysokam/option-fix

Conversation

@heysokam

@heysokam heysokam commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

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.

@treeform
treeform merged commit ce1ea84 into treeform:master Oct 28, 2026
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