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

Can't compile nim on hints part when using Option[string] #78

Closed
EpicUsaMan opened this issue Feb 17, 2020 · 2 comments
Closed

Can't compile nim on hints part when using Option[string] #78

EpicUsaMan opened this issue Feb 17, 2020 · 2 comments

Comments

@EpicUsaMan
Copy link

Error:

fatal.nim(48)            sysFatal
Error: unhandled exception: sons is not accessible [FieldError]

Example code:

type Config = object
    templatePath: Option[string]

var configList: seq[Config]
let fileStream = newFileStream(filename)
load(fileStream, configList)
fileStream.close()
@flyx
Copy link
Owner

flyx commented Feb 25, 2020

This happens because Option is not supported by NimYAML. It would need two functions in yaml/serialization.nim:

proc constructObject*[T](s: var YamlStream, c: ConstructionContext,
                         result: var Option[T])

and

proc representObject*[T](value: Option[T], ts: TagStyle,
    c: SerializationContext, tag: TagId)

I am not actively maintaining NimYAML, but a PR would be welcome.

@flyx flyx closed this as completed in 1dfc2a3 Mar 8, 2020
@flyx
Copy link
Owner

flyx commented Mar 8, 2020

It was a bit trickier than I expected; works as of v0.13.0 which I just released.

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

No branches or pull requests

2 participants