In config.nims, when the os module is imported and paramCount and/or paramStr are used, we get the "ambiguous call" error (because these two are defined in both system and os.
config.nimsimport os # commenting this out fixes the error
# import os except paramCount, paramStr # this also does not give that error
task temp123, "Temp task":
let
numParams = paramCount()
for i in 1 .. numParams:
echo paramStr(i)
/home/kmodi/sandbox/nim/aoc2019/config.nims(3, 6) template/generic instantiation of `task` from here
/home/kmodi/sandbox/nim/aoc2019/config.nims(5, 27) Error: ambiguous call; both system.paramCount() [declared in /home/kmodi/usr_local/apps/6/nim/devel/lib/system/nimscript.nim(65, 6)] and os.paramCount() [declared in /home/kmodi/usr_local/apps/6/nim/devel/lib/pure/os.nim(2613, 8)] match for: ()
No error
import os except paramCount, paramStr, or system. qualifiers with the ambiguous identifiers.$ nim -v
Nim Compiler Version 1.1.1 [Linux: amd64]
Compiled at 2019-12-05
Copyright (c) 2006-2019 by Andreas Rumpf
git hash: 3fbb3bfd3f440c059d6290c12834a38a61da98f2
active boot switches: -d:release
This used to work at some point (probably around Nim 19.x).
We have to do the same thing in nimble as well today.
https://github.com/nim-lang/nimble/blob/master/src/nimblepkg/nimscriptwrapper.nim#L118
Not a bug? Even outside of nimscript, name clashes are possible and you need to use qualified names.
Even outside of nimscript, name clashes are possible and you need to use qualified names.
Is this a slightly different case though?
The name clashes are understood when the they happen among two or more user-imported modules.
In this case, it happens between the implicitly imported system and user imported os.
I believe there was already an internal way in the packages to determine if an stdlib module is imported in a NimScript. If so, something special can probably done to prevent this name clash on doing import os.
os defines param* as error for nimscript and other targets.
Error: unhandled exception: paramCount is not implemented on Nintendo Switch [OSError]
this is clearly not right.
@kaushalmodi https://github.com/nim-lang/Nim/pull/12860
Please send similar PR for any more such issue :)
@nc-x Thank you for working on a PR to fix this!
I would have liked to send a PR to fix this myself, but looking at your PR, I don't think I would have been able to make those fixes myself. But I am always trying ..
@kaushalmodi the original PR was much simpler. It just removed the proc declarations from os.nim for nimscript. And it passed all the tests, unlike now :)
Most helpful comment
osdefinesparam*as error for nimscript and other targets.Error: unhandled exception: paramCount is not implemented on Nintendo Switch [OSError]this is clearly not right.