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

[NimScript] thisDir returns "" when script extension is not provided #10317

Closed Wh1teDuke closed 5 years ago

Wh1teDuke commented 5 years ago

Test.nims:

echo thisDir()

task foo, "bar":
  discard

CMD:

>nim foo Test.nims
[...]/nim/test/test_nims
>nim foo Test
[Empty String]

This wasn't an issue two days ago.


>nim -v
Nim Compiler Version 0.19.9 [Linux: i386]
Compiled at 2019-01-15
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: 4355f23ee5fd53acfdaa8ecb5dbb50f9b43f98b2
active boot switches: -d:release
kaushalmodi commented 5 years ago

Yeah, a "directory" string should never be an empty string; it doesn't make sense as "" directory means nothing.

kaushalmodi commented 5 years ago

This issue feels like a deja vu; I had reported a similar issue ( https://github.com/nim-lang/Nim/issues/9985 ) where projectDir() in .nims returned an empty string, and that is already fixed.

@Araq Is there a way to constrain only the directory string returning functions to never return an empty string? Can the type still be string, but kind of be a subset of the string type where "" is an invalid value?

Araq commented 5 years ago

@kaushalmodi Nothing beyond assert exists for that.

krux02 commented 5 years ago

cannot reproduce. Is it still a problem. With both commands I get the correct directory.

Wh1teDuke commented 5 years ago

cannot reproduce. Is it still a problem. With both commands I get the correct directory.

In my computer the issue persists.

Araq commented 5 years ago

Works for me here too. Unreproducible.