vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.83k stars 789 forks source link

Imprecise Duplicate Import Check #3993

Open cyberthirst opened 3 months ago

cyberthirst commented 3 months ago

Version Information

In ModuleAnalyzer._load_import_helper(), the following check ensures that a given file is not imported multiple times:

if path in self._imported_modules:
    previous_import_stmt = self._imported_modules[path]
    raise DuplicateImport(f"{alias} imported more than once!", previous_import_stmt, node)

However, the check is not performed using a normalized path as it is being done in the input bundle. This means that for a lib1 in the directory project, it can be bypassed as follows:

import lib1
from ..project import lib1 as lib2

Note however that since paths are normalized in the input bundle, if the two modules are initialized, for example, the compiler will raise an exception.

credits: @trocher