Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #22065; do not search path for relative imports #22073

Merged
merged 11 commits into from
Jun 13, 2023
Merged

fixes #22065; do not search path for relative imports #22073

merged 11 commits into from
Jun 13, 2023

Conversation

ringabout
Copy link
Member

fixes #22065

compiler/options.nim Outdated Show resolved Hide resolved
@ringabout ringabout marked this pull request as ready for review June 12, 2023 12:20
@ringabout ringabout changed the title fixes #22065; do not search path for "./" fixes #22065; do not search path for relative imports Jun 12, 2023
@arnetheduck
Copy link
Contributor

btw, something to be aware of is that this kind of "strictness" increase will result in a number of packages failing to compile - this is certainly the case of status' packages which prompted our initial desire for this feature - worst case, this might have to be turned into a warning ("imported from weird location") that can be turned into an error

@ringabout
Copy link
Member Author

ringabout commented Jun 12, 2023

something to be aware of is that this kind of "strictness" increase will result in a number of packages failing to compile - this is certainly the case of status' packages which prompted our initial desire for this feature - worst case, this might have to be turned into a warning ("imported from weird location") that can be turned into an error

As to important packages, only arraymancer uses ./math. I will add a changelog. A compile error is good, no to mention, ./math doesn't actually make sense, which can be though of a bug. Warnings + warnAsError might be a better solution, though.

@Araq Araq merged commit cca5e5f into devel Jun 13, 2023
@Araq Araq deleted the pr_relative branch June 13, 2023 11:23
@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from cca5e5f

Hint: mm: orc; opt: speed; options: -d:release
167827 lines; 10.871s; 610.969MiB peakmem

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait .. only stdlib or also -p:path? ie the latter should also not be searched

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, make sense, I will correct the changelog.

bung87 pushed a commit to bung87/Nim that referenced this pull request Jul 29, 2023
…ng#22073)

* fixes nim-lang#22065; do not search path for "./"

* simplify

* fixes

* fixes

* allow ".."

* cleanup

* add a test case

* slightly modify the import

* adds a changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

import ./modulename ignores the ./ path prefix
4 participants