mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +00:00
* documents #21628 * Update doc/manual.md --------- Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
This commit is contained in:
@@ -6889,6 +6889,35 @@ iterator in which case the overloading resolution takes place:
|
||||
var x = 4
|
||||
write(stdout, x) # not ambiguous: uses the module C's x
|
||||
```
|
||||
Modules can share their name, however, when trying to qualify a identifier with the module name the compiler will fail with ambiguous identifier error. One can qualify the identifier by aliasing the module.
|
||||
|
||||
|
||||
```nim
|
||||
# Module A/C
|
||||
proc fb* = echo "fizz"
|
||||
```
|
||||
|
||||
|
||||
```nim
|
||||
# Module B/C
|
||||
proc fb* = echo "buzz"
|
||||
```
|
||||
|
||||
|
||||
```nim
|
||||
import A/C
|
||||
import B/C
|
||||
|
||||
C.fb() # Error: ambiguous identifier: 'fb'
|
||||
```
|
||||
|
||||
|
||||
```nim
|
||||
import A/C as fizz
|
||||
import B/C
|
||||
|
||||
fizz.fb() # Works
|
||||
```
|
||||
|
||||
|
||||
Packages
|
||||
|
||||
Reference in New Issue
Block a user