From fa058773db018405ff218bc8ff4682a192e9131f Mon Sep 17 00:00:00 2001 From: Miran Date: Thu, 31 Jan 2019 08:20:00 +0100 Subject: [PATCH] fixes #10042 (allow spaces in import) (#10504) This allows spaces in imports, by using the following syntax: * `import "directory with spaces" / subdir / file`, or * `import "directory with spaces/subdir/file"` --- compiler/modulepaths.nim | 1 - tests/dir with space/more spaces/mspace.nim | 1 + tests/dir with space/tspace.nim | 4 ++++ 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tests/dir with space/more spaces/mspace.nim diff --git a/compiler/modulepaths.nim b/compiler/modulepaths.nim index 9e27a2d7d5..129f719e25 100644 --- a/compiler/modulepaths.nim +++ b/compiler/modulepaths.nim @@ -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 diff --git a/tests/dir with space/more spaces/mspace.nim b/tests/dir with space/more spaces/mspace.nim new file mode 100644 index 0000000000..bc2c90f5ea --- /dev/null +++ b/tests/dir with space/more spaces/mspace.nim @@ -0,0 +1 @@ +proc tenTimes*(x: int): int = 10*x diff --git a/tests/dir with space/tspace.nim b/tests/dir with space/tspace.nim index 59237c9a16..87a52c2713 100644 --- a/tests/dir with space/tspace.nim +++ b/tests/dir with space/tspace.nim @@ -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")