Skip to content

Commit

Permalink
fixes nim-lang#10042 (allow spaces in import) (nim-lang#10504)
Browse files Browse the repository at this point in the history
This allows spaces in imports, by using the following syntax:
* `import "directory with spaces" / subdir / file`, or
* `import "directory with spaces/subdir/file"`
  • Loading branch information
narimiran authored and Araq committed Jan 31, 2019
1 parent 81e5a35 commit fa05877
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion compiler/modulepaths.nim
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ proc getModuleName*(conf: ConfigRef; n: PNode): string =
try:
result =
pathSubs(conf, n.strVal, toFullPath(conf, n.info).splitFile().dir)
.replace(" ")
except ValueError:
localError(conf, n.info, "invalid path: " & n.strVal)
result = n.strVal
Expand Down
1 change: 1 addition & 0 deletions tests/dir with space/more spaces/mspace.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
proc tenTimes*(x: int): int = 10*x
4 changes: 4 additions & 0 deletions tests/dir with space/tspace.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ discard """
output: "Successful"
"""
# Test for the compiler to be able to compile a Nim file with spaces in the directory name.
# Also test if import of a directory with a space works.

import "more spaces" / mspace

assert tenTimes(5) == 50
echo("Successful")

0 comments on commit fa05877

Please sign in to comment.