replace defer by try/finally to avoid 0.19.6 compiler bug (#15)

This commit is contained in:
Mamy Ratsimbazafy 2019-09-11 14:09:58 -04:00 committed by GitHub
parent 80da30b031
commit 448a03ed4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 11 deletions

View File

@ -89,11 +89,7 @@ template loadFile*(Format: distinct type,
params: varargs[untyped]): auto =
mixin init, ReaderType
var stream = openFile(filename)
defer:
# TODO: destructors
if not stream.isNil:
stream[].close()
try:
# TODO:
# Remove this when statement once the following bug is fixed:
# https://github.com/nim-lang/Nim/issues/9996
@ -103,6 +99,10 @@ template loadFile*(Format: distinct type,
var reader = init(ReaderType(Format), stream)
reader.readValue(RecordType)
finally:
# TODO: destructors
if not stream.isNil:
stream[].close()
template loadFile*[RecordType](Format: type,
filename: string,