Fixed: dispose file even if an error occurs.

This commit is contained in:
arookas 2015-12-12 16:52:34 -05:00
parent 2fcab65c22
commit 8d899d019a

View file

@ -87,14 +87,20 @@ namespace arookas
sunScriptFile file; sunScriptFile file;
var result = ImportResolver.ResolveImport(name, out file); var result = ImportResolver.ResolveImport(name, out file);
if (result == sunImportResult.Loaded) if (result == sunImportResult.Loaded)
{
try
{ {
ImportResolver.EnterFile(file); ImportResolver.EnterFile(file);
var parser = new sunParser(); var parser = new sunParser();
var tree = parser.Parse(file); var tree = parser.Parse(file);
tree.Compile(this); tree.Compile(this);
ImportResolver.ExitFile(file); ImportResolver.ExitFile(file);
}
finally
{
file.Dispose(); file.Dispose();
} }
}
return result; return result;
} }