replace defer by try/finally to avoid 0.19.6 compiler bug (#15)
This commit is contained in:
parent
80da30b031
commit
448a03ed4b
|
@ -89,21 +89,21 @@ template loadFile*(Format: distinct type,
|
|||
params: varargs[untyped]): auto =
|
||||
mixin init, ReaderType
|
||||
var stream = openFile(filename)
|
||||
defer:
|
||||
try:
|
||||
# TODO:
|
||||
# Remove this when statement once the following bug is fixed:
|
||||
# https://github.com/nim-lang/Nim/issues/9996
|
||||
when astToStr(params) != "":
|
||||
var reader = init(ReaderType(Format), stream, params)
|
||||
else:
|
||||
var reader = init(ReaderType(Format), stream)
|
||||
|
||||
reader.readValue(RecordType)
|
||||
finally:
|
||||
# TODO: destructors
|
||||
if not stream.isNil:
|
||||
stream[].close()
|
||||
|
||||
# TODO:
|
||||
# Remove this when statement once the following bug is fixed:
|
||||
# https://github.com/nim-lang/Nim/issues/9996
|
||||
when astToStr(params) != "":
|
||||
var reader = init(ReaderType(Format), stream, params)
|
||||
else:
|
||||
var reader = init(ReaderType(Format), stream)
|
||||
|
||||
reader.readValue(RecordType)
|
||||
|
||||
template loadFile*[RecordType](Format: type,
|
||||
filename: string,
|
||||
record: var RecordType,
|
||||
|
|
Loading…
Reference in New Issue