nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

Regression in distros.nim (foreignDep fails to compile) #10024

Closed andreaferretti closed 5 years ago

andreaferretti commented 5 years ago

Running nimble test on neo fails with

 Error: Could not read package info file in /Users/andrea/progetti/neo/neo.nimble;
        ...   Reading as ini file failed with: 
        ...     Invalid section: .
        ...   Evaluating as NimScript file failed with: 
        ...     /Users/andrea/.mynim/devel/lib/pure/distros.nim(191, 5) Error: undeclared identifier: 'nimscriptapi'.

Apparently the culprit is the following block in neo.nimble:

when defined(nimdistros):
  import distros
  if detectOs(Ubuntu) or detectOs(Debian):
    foreignDep "libblas-dev"
    foreignDep "libopenblas-dev"
    foreignDep "liblapack-dev"
  else:
    foreignDep "libblas"
    foreignDep "liblapack"

which in turn triggers the failure at this line

andreaferretti commented 5 years ago

By the way, the easiest way to reproduce is to use any nimble file which contains

when defined(nimdistros):
  import distros

  foreignDep "foo"

It seems this only affects nimble, because of this line

when defined(nimble):
  nimscriptapi.foreignDeps.add(c)

Now, according to git blame, these lines have been there since nimscripts exists, more or less. I am not sure what is going on, but it seems that foreignDep at the moment is completely unusable for me. Can anyone else confirm?