Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Warn when an import shadows a locally defined function #26

Open
fcasal opened this issue Jun 16, 2022 · 1 comment
Open

Warn when an import shadows a locally defined function #26

fcasal opened this issue Jun 16, 2022 · 1 comment
Labels
new rule Proposal for a new rule.

Comments

@fcasal
Copy link
Collaborator

fcasal commented Jun 16, 2022

We would flag the following foo import

# library.cairo

func foo() -> ():
end

and

# main.cairo
from library import foo as bar

func bar() -> ():
end

func main() -> ():
    bar()
end

This should also work for unaliased import.

We should also check the compiler behavior so we could provide further details when this is found.

@fcasal fcasal added the new rule Proposal for a new rule. label Jun 16, 2022
@coolhill
Copy link
Contributor

The compiler seem to cover this case, both for aliased/unaliased imports.

$ cairo-compile main.cairo
main.cairo:3:6: Redefinition of '__main__.bar'.
func bar() -> ():
     ^*^

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new rule Proposal for a new rule.
Projects
None yet
Development

No branches or pull requests

2 participants