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

Error: can raise an unlisted exception #19

Closed
andreaferretti opened this issue Jun 29, 2016 · 3 comments
Closed

Error: can raise an unlisted exception #19

andreaferretti opened this issue Jun 29, 2016 · 3 comments

Comments

@andreaferretti
Copy link
Contributor

Apparently, this arises when trying to serialize anything that contains a table. A small example would be

import streams, yaml, tables

var
  t = {"a": "b"}.newTable()
  s = newFileStream("test.yaml", fmWrite)
dump(t, s)
s.close()

It seems that this happens because representChild is explicit defined not to raise exceptions, but accessing table keys can raise KeyError.

I think one should either catch that exception, or remove the explicit pragma {. raises: [] .} and let the compiler infer effects

@flyx
Copy link
Owner

flyx commented Jun 29, 2016

Yeah, exception handling seems to have been improved a bit since 0.13.1 and detects things it didn't when I wrote the code :). I'll fix it tomorrow.

Also, this indicates NimYAML needs more tests.

@flyx
Copy link
Owner

flyx commented Jun 30, 2016

This is an interesting one. I do not see how the source line the compiler complains about can raise this exception, and I also cannot wrap it with try/catch - the compiler still complains.

Accessing table keys is done with the pairs iterator which does not yield a KeyError.

Might be a compiler regression, or something so subtle I did not find it yet. I do not want to lose the guarantee {. raises [] .} everywhere. Will need some time to figure it out.

@flyx
Copy link
Owner

flyx commented Jul 7, 2016

This was one badass bug.

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