You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
In shoco.odin, I found that the symbol compress is declared by both an import statement and a procedure.Instead of getting an error like "identifier compress already defined", the imported name silently takes precedence over the local one.
Example:
import"path/to/apackage"// The imported `apackage` takes precedence over the local `apackage` procedure.
p :: proc() -> apackage.Some_Type {
}
apackage :: proc () {
}
What happens:
The imported name apackage is used, and the local procedure apackage is ignored. This compiles without errors.
What I expected:
An error about a name conflict, like: identifier apackage already defined
How Go handles it:
In Go, if an imported package name conflicts with a local identifier, the compiler throws an error:
Question:
Is this behavior intentional? It feels a bit unintuitive. Should imports really take precedence over local definitions?
The text was updated successfully, but these errors were encountered:
obiwan87
changed the title
Import name overrides local procedure with the same name
Import name shadows procedure with the same name
Dec 17, 2024
Description:
In
shoco.odin
, I found that the symbolcompress
is declared by both an import statement and a procedure.Instead of getting an error like "identifiercompress
already defined", the imported name silently takes precedence over the local one.Example:
What happens:
The imported name
apackage
is used, and the local procedureapackage
is ignored. This compiles without errors.What I expected:
An error about a name conflict, like:
identifier apackage already defined
How Go handles it:
In Go, if an imported package name conflicts with a local identifier, the compiler throws an error:
Question:
Is this behavior intentional? It feels a bit unintuitive. Should imports really take precedence over local definitions?
The text was updated successfully, but these errors were encountered: