Open Vladar4 opened 3 years ago
The foo_bar
with underscore is right to be treated differently, and any said "manual vaguely implies" should be fixed instead.
But if foobar
is a Nim-package, then import foobar
and import fooBar
being treated differently is an issue, which should be fixed, for example, forbid packages from mixing upper-case, or simply import case-insensitive.
However, if foobar
is a .nim
file, then Nim should import case-sensitive even if on Windows OS, to ensure that code compiles for our macOS co-workers as well.
!nim c
import parseUtils # works
import std/strUtils # fails
import seq_utils # fails
0 (0 bytes)
```cpp
```
2024-09-23T11:22:15
2024-09-23T11:22:15
now
0 (0 bytes)
```cpp
```
2024-09-23T11:22:18
2024-09-23T11:22:18
now
0 (0 bytes)
```cpp
```
2024-09-23T11:22:18
2024-09-23T11:22:18
now
0 (0 bytes)
```cpp
```
2024-09-23T11:22:21
2024-09-23T11:22:21
now
0 (0 bytes)
```cpp
```
2024-09-23T11:22:23
2024-09-23T11:22:23
now
0 (0 bytes)
```cpp
```
2024-09-23T11:22:25
2024-09-23T11:22:25
now
0 (0 bytes)
```cpp
```
2024-09-23T11:22:27
2024-09-23T11:22:27
now
0 (0 bytes)
```cpp
```
2024-09-23T11:22:29
2024-09-23T11:22:29
now
11.4.0
14.0.0
20.4
2024-09-23T11:21:48Z
2
nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
:robot: Bug found in 16 mins
bisecting 8
commits at 0
commits per second
!nim c
import seq_utils
Repeated but simplified just to show the non-std/
-qualified import
with style variation also fails on all hot-loadable test Nim versions.
0 (0 bytes)
```cpp
```
2024-09-23T11:26:26
2024-09-23T11:26:26
0 (0 bytes)
```cpp
```
2024-09-23T11:26:30
2024-09-23T11:26:30
now
0 (0 bytes)
```cpp
```
2024-09-23T11:26:30
2024-09-23T11:26:30
now
0 (0 bytes)
```cpp
```
2024-09-23T11:26:34
2024-09-23T11:26:34
now
0 (0 bytes)
```cpp
```
2024-09-23T11:26:37
2024-09-23T11:26:37
now
0 (0 bytes)
```cpp
```
2024-09-23T11:26:40
2024-09-23T11:26:40
now
0 (0 bytes)
```cpp
```
2024-09-23T11:26:42
2024-09-23T11:26:42
now
0 (0 bytes)
```cpp
```
2024-09-23T11:26:43
2024-09-23T11:26:43
now
11.4.0
14.0.0
20.4
2024-09-23T11:25:54Z
4
nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
:robot: Bug found in 20 mins
bisecting 8
commits at 0
commits per second
Only needs to be documented, Nim first tries the name as written and then in all lowercase.
It seems the std/
package qualification also changes things...
The manual vaguely implies that module names should follow identifier equality rules (so, partial case-insensitivity and underscore is ignored).
https://nim-lang.org/docs/manual.html#modules https://nim-lang.org/docs/manual.html#lexical-analysis-identifier-equality
But it appears that import statements treat
foobar
,foo_bar
, orfooBar
as different modules.Example
Current Output
Expected Output
Normal compilation conforming to identifier equality.
Possible Solution
If I am mistaken about the idea that import statement should follow identifier equality rules, it would be helpful if it was reflected in the manual. Otherwise there is a bug in the import statement.
Additional Information
Original discussion: https://github.com/Vladar4/sdl2_nim/issues/35#issuecomment-835403915