Skip to content

import os + use of existsDir/dirExists/existsFile/fileExists/findExe in config.nims causes "ambiguous call' error #14142

Closed
@kaushalmodi

Description

In config.nims, when the os module is imported and one of these procs are used:

  • existsDir or dirExists
  • existsFile or fileExists
  • findExe

we get the "ambiguous call" error (because these are defined in both system and os.

Example config.nims

  1. Create this config.nims in any directory
  2. Run nim temp123
# config.nims
import os # commenting this out fixes the error
# import os except existsDir, dirExists, existsFile, fileExists, findExe # this also does not give that error

task temp123, "Temp task":
  echo existsDir("/usr")
  echo dirExists("/usr")
  echo existsFile("/usr/foo")
  echo fileExists("/usr/foo")
  echo findExe("nim")

Current Output

/home/kmodi/sandbox/nim/bug_reports/nimscript_import_os/config.nims(4, 6) template/generic instantiation of `task` from here
/home/kmodi/sandbox/nim/bug_reports/nimscript_import_os/config.nims(5, 17) Error: ambiguous call; both system.existsDir(dir: string) [declared in /home/kmodi/usr_local/apps/6/nim/devel/lib/system/nimscript.nim(135, 6)] and os.existsDir(dir: string) [declared in /home/kmodi/usr_local/apps/6/nim/devel/lib/pure/os.nim(1109, 6)] match for: (string)

Expected Output

Outputs of the echo statements in the above example.

Workaround

  • Use import os except existsDir, dirExists, existsFile, fileExists, findExe, or system. qualifiers with the ambiguous identifiers.

Additional Information

This issue is very closely related to #12835 .

$ nim -v
Nim Compiler Version 1.3.1 [Linux: amd64]
Compiled at 2020-04-27
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 2f1aad02642576d13df018c9e5869c8de7e3a539
active boot switches: -d:release

This used to work at some point (probably around Nim 19.x).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions