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

import os + use of paramCount and paramStr in config.nims causes "ambiguous call' error #12835

Closed
kaushalmodi opened this issue Dec 7, 2019 · 7 comments · Fixed by #12860
Closed

Comments

@kaushalmodi
Copy link
Contributor

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.

Example config.nims

import 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)

Current Output

/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: ()

Expected Output

No error

Workaround

  • Use import os except paramCount, paramStr, or system. qualifiers with the ambiguous identifiers.

Additional Information

$ 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).

@genotrance
Copy link
Contributor

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

@nc-x
Copy link
Contributor

nc-x commented Dec 8, 2019

Not a bug? Even outside of nimscript, name clashes are possible and you need to use qualified names.

@kaushalmodi
Copy link
Contributor Author

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.

@SolitudeSF
Copy link
Contributor

SolitudeSF commented Dec 8, 2019

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.

@nc-x
Copy link
Contributor

nc-x commented Dec 9, 2019

@kaushalmodi #12860

Please send similar PR for any more such issue :)

@kaushalmodi
Copy link
Contributor Author

@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 ..

@nc-x
Copy link
Contributor

nc-x commented Dec 10, 2019

@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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants