jacylang / jacy

Jacy programming language
https://jacylang.github.io
13 stars 1 forks source link

Function overloads importation #8

Open hazer-hazer opened 3 years ago

hazer-hazer commented 3 years ago

Let's begin with an example:

mod m {
     pub func foo(label1: int);
}

mod n {
    use m::foo;
    func foo(label2: int);
}

Now, the importer operates on the names of item groups, i.e. in module m and in module n items with the name foo exist. The module tree does not store direct information about suffixes, that is (label1:) and (label2:), thus in the importation of module m to module n the Importer tries to redefine function group foo rather than adds new overload foo(label1:).

What to do

Update Importer, change workflow for function overloads redefinitions:

Why report an error with all redefined overloads? - It might be hard to comprehend the workflow if imported function overload overlaps one already defined in the module.

Alternative

Do nothing, disallow merging imported functions with already defined.