mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
* fixes #22065; do not search path for "./" * simplify * fixes * fixes * allow ".." * cleanup * add a test case * slightly modify the import * adds a changelog
This commit is contained in:
@@ -260,6 +260,8 @@
|
||||
|
||||
- `strutils.split` and `strutils.rsplit` now forbid an empty separator.
|
||||
|
||||
- Relative imports will not resolve to stdlib anymore, e.g. `import ./tables` now reports an error properly.
|
||||
|
||||
## Standard library additions and changes
|
||||
|
||||
[//]: # "Changes:"
|
||||
|
||||
@@ -910,6 +910,7 @@ proc findFile*(conf: ConfigRef; f: string; suppressStdlib = false): AbsoluteFile
|
||||
proc findModule*(conf: ConfigRef; modulename, currentModule: string): AbsoluteFile =
|
||||
# returns path to module
|
||||
var m = addFileExt(modulename, NimExt)
|
||||
var hasRelativeDot = false
|
||||
if m.startsWith(pkgPrefix):
|
||||
result = findFile(conf, m.substr(pkgPrefix.len), suppressStdlib = true)
|
||||
else:
|
||||
@@ -923,7 +924,11 @@ proc findModule*(conf: ConfigRef; modulename, currentModule: string): AbsoluteFi
|
||||
else: # If prefixed with std/ why would we add the current module path!
|
||||
let currentPath = currentModule.splitFile.dir
|
||||
result = AbsoluteFile currentPath / m
|
||||
if not fileExists(result):
|
||||
if m.startsWith('.') and not fileExists(result):
|
||||
result = AbsoluteFile ""
|
||||
hasRelativeDot = true
|
||||
|
||||
if not fileExists(result) and not hasRelativeDot:
|
||||
result = findFile(conf, m)
|
||||
patchModule(conf)
|
||||
|
||||
|
||||
5
tests/import/t22065.nim
Normal file
5
tests/import/t22065.nim
Normal file
@@ -0,0 +1,5 @@
|
||||
discard """
|
||||
errormsg: "cannot open file: ./sugar"
|
||||
"""
|
||||
|
||||
import ./sugar
|
||||
Reference in New Issue
Block a user