Nim
                                
                                
                                
                                    Nim copied to clipboard
                            
                            
                            
                        Import statement does not follow identifier equality rules
The manual vaguely implies that module names should follow identifier equality rules (so, partial case-insensitivity and underscore is ignored).
A valid module name can only be a valid Nim identifier
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, or fooBar as different modules.
Example
import foobar
import foo_bar
import fooBar
# with only `foobar.nim` file present all three cases should work identically.
Current Output
Error: cannot open file: foo_bar
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
$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
git hash: 3645f5fc7ae885e22cb52b9f865edf062cfb8e59
                                    
                                    
                                    
                                
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
                                    
                                    
                                    
                                
:penguin: Linux bisect by @c-blake (contributor)
devel :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:22:15 - Finished	
2024-09-23T11:22:15 - Duration	
now 
AST
stable :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:22:18 - Finished	
2024-09-23T11:22:18 - Duration	
now 
AST
2.0.8 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:22:18 - Finished	
2024-09-23T11:22:18 - Duration	
now 
AST
2.0.0 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:22:21 - Finished	
2024-09-23T11:22:21 - Duration	
now 
AST
1.6.20 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:22:23 - Finished	
2024-09-23T11:22:23 - Duration	
now 
AST
1.4.8 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:22:25 - Finished	
2024-09-23T11:22:25 - Duration	
now 
AST
1.2.18 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:22:27 - Finished	
2024-09-23T11:22:27 - Duration	
now 
AST
1.0.10 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:22:29 - Finished	
2024-09-23T11:22:29 - Duration	
now 
AST
Stats
- GCC	
11.4.0 - Clang	
14.0.0 - NodeJS	
20.4 - Created	
2024-09-23T11:21:48Z - Comments	
2 - Commands	
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.
:penguin: Linux bisect by @c-blake (contributor)
devel :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:26:26 - Finished	
2024-09-23T11:26:26 - Duration	
 
AST
stable :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:26:30 - Finished	
2024-09-23T11:26:30 - Duration	
now 
AST
2.0.8 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:26:30 - Finished	
2024-09-23T11:26:30 - Duration	
now 
AST
2.0.0 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:26:34 - Finished	
2024-09-23T11:26:34 - Duration	
now 
AST
1.6.20 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:26:37 - Finished	
2024-09-23T11:26:37 - Duration	
now 
AST
1.4.8 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:26:40 - Finished	
2024-09-23T11:26:40 - Duration	
now 
AST
1.2.18 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:26:42 - Finished	
2024-09-23T11:26:42 - Duration	
now 
AST
1.0.10 :-1: FAIL
Output
IR
Compiled filesize0 (0 bytes)
Stats
- Started	
2024-09-23T11:26:43 - Finished	
2024-09-23T11:26:43 - Duration	
now 
AST
Stats
- GCC	
11.4.0 - Clang	
14.0.0 - NodeJS	
20.4 - Created	
2024-09-23T11:25:54Z - Comments	
4 - Commands	
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...