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

Import name shadows procedure with the same name #4590

Open
obiwan87 opened this issue Dec 17, 2024 · 0 comments
Open

Import name shadows procedure with the same name #4590

obiwan87 opened this issue Dec 17, 2024 · 0 comments

Comments

@obiwan87
Copy link
Contributor

obiwan87 commented Dec 17, 2024

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:
image

Question:

Is this behavior intentional? It feels a bit unintuitive. Should imports really take precedence over local definitions?

@obiwan87 obiwan87 changed the title Import name overrides local procedure with the same name Import name shadows procedure with the same name Dec 17, 2024
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

No branches or pull requests

1 participant