Skip to content
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

nim e fails with incorrect error if file does not exist or if script file gets deleted during execution #11165

Closed
genotrance opened this issue May 2, 2019 · 3 comments

Comments

@genotrance
Copy link
Contributor

Similar to how batch files die if the file gets modified or deleted during execution.

If you have a nimscript file a.nims with:

rmFile("a.nims")

Running this script gives random error about filename. This affected nimble's nocompiler feature (removing compiler from nimble). As noted by @andreaferretti in nim-lang/nimble#635 (comment), since nimble is being called recursively, the nims file copied by parent process gets deleted by child process.

I am fixing this in nimble separately (don't delete if you didn't copy it in the first place) but it seems this might bite others as well. The use case might not be too common but interesting to document at the very least.

Error (with stack trace) is:

# > nim_temp e a.nims
(1, 21) Error: undeclared identifier: 'a'
Traceback (most recent call last)
nim.nim(98)              nim
nim.nim(75)              handleCmdLine
cmdlinehelper.nim(92)    loadConfigsAndRunMainCommand
main.nim(347)            mainCommand
main.nim(156)            commandEval
main.nim(149)            evalNim
passes.nim(66)           carryPasses
passes.nim(57)           carryPass
sem.nim(603)             myProcess
sem.nim(571)             semStmtAndGenerateGenerics
semstmts.nim(2159)       semStmt
semexprs.nim(939)        semExprNoType
semexprs.nim(2657)       semExpr
semstmts.nim(2099)       semStmtList
semexprs.nim(2561)       semExpr
semexprs.nim(2165)       semMagic
semexprs.nim(920)        semDirectOp
semexprs.nim(770)        semOverloadedCallAnalyseEffects
semcall.nim(524)         semOverloadedCall
semcall.nim(326)         resolveOverloads
semcall.nim(93)          pickBestCandidate
sigmatch.nim(2462)       matches
sigmatch.nim(2402)       matchesAux
sigmatch.nim(2214)       prepareOperand
semexprs.nim(49)         semOperand
semexprs.nim(2561)       semExpr
semexprs.nim(2165)       semMagic
semexprs.nim(920)        semDirectOp
semexprs.nim(770)        semOverloadedCallAnalyseEffects
semcall.nim(524)         semOverloadedCall
semcall.nim(326)         resolveOverloads
semcall.nim(93)          pickBestCandidate
sigmatch.nim(2462)       matches
sigmatch.nim(2402)       matchesAux
sigmatch.nim(2214)       prepareOperand
semexprs.nim(49)         semOperand
semexprs.nim(2512)       semExpr
semexprs.nim(1356)       semFieldAccess
semexprs.nim(1210)       builtinFieldAccess
lookups.nim(328)         qualifiedLookUp
lookups.nim(317)         qualifiedLookUp
lookups.nim(272)         errorUndeclaredIdentifier
msgs.nim(530)            localError
msgs.nim(515)            liMessage
msgs.nim(346)            handleError
msgs.nim(331)            quit
@timotheecour
Copy link
Member

maybe related:
nim e main.nim fails with a really bad error msg when extension is wrong (nim instead of nims):

./bin/nim e --skipUserCfg $timn_D/tests/nim/all/t0538.nim
Hint: used config file '/Users/timothee/git_clone/nim/Nim_devel/config/nim.cfg' [Conf]
Hint: used config file '/Users/timothee/git_clone/nim/timn/nim.cfg' [Conf]
Hint: used config file '/Users/timothee/git_clone/nim/Nim_devel/config/config.nims' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: stdin [Processing]
(1, 57) Error: undeclared identifier: '//'

passing --verbosity:3 is equally unhelpful

@genotrance
Copy link
Contributor Author

genotrance commented Jul 19, 2019

Just to clarify again - the way I found the issue is not the typical use case. Fact is that if you run nim e with a bad filename, you get an unrelated error and it isn't clear what happened. You can also recreate the issue by deleting the file at runtime.

(1, 21) Error: undeclared identifier: 'a' suggests that there's a problem in the file contents, not that the file doesn't even exist or got deleted during execution.

Similar to @timotheecour's report, .nim extension is not support for nim e but you don't get a helpful error.

@genotrance genotrance changed the title nim e fails if script file gets deleted during execution nim e fails with incorrect error if file does not exist or if script file gets deleted during execution Jul 19, 2019
@Araq
Copy link
Member

Araq commented Aug 18, 2019

Should be fixed by #11961

@Araq Araq closed this as completed Aug 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants