Closed kobi2187 closed 5 years ago
Is there no additional information after the last error line you posted?
Also, your sources do not seem to be up-to-date. serialization.nim:218 is an empty line and cannot possibly produce an error. Try updating with nimble.
the line numbers are different because I use vscode, which automatically runs nimpretty. I reinstalled it just to make sure. Now I get these lines:
/home/kobi7/.nimble/pkgs/yaml-#head/yaml/serialization.nim(159, 15) template/generic instantiation from here
/home/kobi7/.nimble/pkgs/yaml-#head/yaml/serialization.nim(146, 33) Error: can raise an unlisted exception:
It is strange that the compiler complains about a missing exception, but then cannot tell me which one.
Indeed. Are you on Nim devel? If so, maybe check with Nim devs first (IRC or issue tracker). The compiler not telling you which exception it misses hints to a problem in the compiler.
Did you try to compile on command line without vscode? I think it's very strange that the vscode plugin reformats imported code; that should be just forbidden. Anyway, it can also be that vscode cuts away an additional error information line.
yes, on nim devel.
I compiled from the command line. at first I thought it was because of -d:ssl that I used in my code,
but cwd to yaml pkg, and nim c yaml.nim
gave the same error.
the vscode plugin reformats any nim file that you have opened, immediately before saving it.
about the missing information line, I suspected vscode's inner terminal too, but it appears exactly the same in a regular bash "gnome-terminal".
if I have some time I'll file a bug report, see what they think.
Thanks!
filed a bug report: https://github.com/nim-lang/Nim/issues/10579
they're so fast. ok, so there is a stopgap fix in the nim compiler. I am not sure it's optimal, now it reports Exception is missing. I think we can change the code later when nim improves further. I just added Exception in all the raises that were referenced in the errors. https://github.com/kobi2187/NimYAML/commit/ddacd98cf71b44bfa7cdb50a01a1aa13ab01ab3c
Would you like a pull request? I am new to git and not sure why it tells me I am 2 commits behind and 3 ahead, or how to fix it.
I've just run into the same problem. I've bisected Nim devel branch to see when this stopped working, and it is https://github.com/nim-lang/Nim/commit/3ce6b2acb9ce21d33f0f14161b0abf89a9ff7af9 (cc @LemonBoy).
Here is a code block from serialization.nim
where (first) error occurs:
template constructScalarItem*(s: var YamlStream, i: untyped,
t: typedesc, content: untyped) =
## Helper template for implementing ``constructObject`` for types that
## are constructed from a scalar. ``i`` is the identifier that holds
## the scalar as ``YamlStreamEvent`` in the content. Exceptions raised in
## the content will be automatically catched and wrapped in
## ``YamlConstructionError``, which will then be raised.
bind constructionError
let i = s.next()
if i.kind != yamlScalar:
raise constructionError(s, "Expected scalar")
try: content
except YamlConstructionError: raise ###################### "Error: can raise an unlisted exception: Exception"
except Exception:
var e = constructionError(s,
"Cannot construct to " & name(t) & ": " & item.scalarContent &
"; error: " & getCurrentExceptionMsg())
e.parent = getCurrentException()
raise e
Similar stuff happens on line 1224, in this block:
case e.kind
of yamlScalar: removeAnchor(e.scalarAnchor)
of yamlStartMap: removeAnchor(e.mapAnchor)
of yamlStartSeq: removeAnchor(e.seqAnchor)
else: internalError("Unexpected event kind: " & $e.kind)
s.peek = e
try: constructChild(s, c, result[])
except YamlConstructionError, YamlStreamError: raise ############### "Error: can raise an unlisted exception: Exception"
except Exception:
var e = newException(YamlStreamError, getCurrentExceptionMsg())
e.parent = getCurrentException()
raise e
If you change that line to something like except YamlConstructionError: raise constructionError(s, "foo")
, then this works, but the next error is here:
proc construct*[T](s: var YamlStream, target: var T)
{.raises: [YamlStreamError].} =
## Constructs a Nim value from a YAML stream.
var context = newConstructionContext()
try:
var e = s.next()
yAssert(e.kind == yamlStartDoc)
constructChild(s, context, target)
e = s.next()
yAssert(e.kind == yamlEndDoc)
except YamlConstructionError:
raise (ref YamlConstructionError)(getCurrentException()) ################### "Error: can raise an unlisted exception: ref YamlConstructionError"
except YamlStreamError:
let cur = getCurrentException()
var e = newException(YamlStreamError, cur.msg)
e.parent = cur.parent
raise e
except Exception:
# may occur while calling s()
var ex = newException(YamlStreamError, "")
ex.parent = getCurrentException()
raise ex
Yeah, previously the compiler completely failed to compute what exceptions are raised and what are caught by a try
/catch
/finally
block.
Re-raising an exception with raise
now correctly warns that either RaiseError
or a generic one will be raised (we just say Exception
since the former is a subclass). Even though the raise
is in a except
branch the compiler is not (yet) able to find out what specific exception type it will raise.
Lastest, seems queues
module is gone
Error: cannot open file: queues
$ nim -V
Nim Compiler Version 0.19.9 [Linux: amd64]
Compiled at 2019-05-03
Copyright (c) 2006-2019 by Andreas Rumpf
active boot switches: -d:release
yes,
in presenter.nim
:
you need to replace it with deques
and change a few calls to the correct api.
I've had little time on my hands to send a pr - here's how to solve it
proc nextItem(c: var
Deque, s: var YamlStream):
try: result = c.
popFirst
cached =
initDeQue[YamlStreamEvent]()
cached.
addLast(next)
This should be fixed with #71.
Does it work for you? I get:
I don't know what's wrong. something is amiss with the pragma raises. if it's only on my computer, can we debug this together? I would like to still use yaml files in my project.