Skip to content

Function overloads importation #8

@hazer-hazer

Description

@hazer-hazer

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:

  • Try to define name binding with name foo, if it wasn't a FOS (Function Overload Set) then it is an error
  • If the user tried to redefine FOS with new FOS -- check all overloads suffixes of redefined FOS and report an error with a collection of all redefined overloads

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.

Metadata

Metadata

Assignees

Labels

invalidThis doesn't seem right

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions