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
top level defer is executed when it encounters import #10186
Comments
I think the top level defer is causing the problem. For this use case you don't technically need the defer. When the process terminates the operating system will reliably close all remaining open file handles for you. |
defer is executing when it encounters import |
Why is a toplevel |
I guess somebody "fixed" that limitation. |
The code is still there Lines 558 to 560 in be0a4d1
|
NG Example
Current Output
OK Example
Output
Success executing.
Other close Example
Output
$ nim c -r open.nim end $ cat test.txt | wc 0 0 0
Possible Solution
I think that executing 'import' then
defer s.close
is executed too.This problem can be avoided, write imports at the beginning of the file.
Is it bad for compiler that writing the 'import' in the middle of file?
The text was updated successfully, but these errors were encountered: