You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is sufficient to check each overload pair in a context once. Currently each function decl is checked subsequently, which results in overload pairs being checked multiple times.
funcfoo(arg: Int) {} // this will be 'a'funcfoo(arg: Bool) {} // this will be 'b'funcfoo(arg: String) {} // this will be 'c'// CHECK FOR REDECL a: (a, a), (a, b), (a, c)// CHECK FOR REDECL b: (b, a), (b, b), (b, c) // (b, a) is redundant// CHECK FOR REDECL c: (c, a), (c, b), (c, c) // all redundantn^2checksinsteadofn*(n+1)/2
The text was updated successfully, but these errors were encountered:
That's not quite true because of private functions, which are only checked in the file where they're defined, but yes, there are improvements to be made here.
@belkadan The part about redundant checks when we have a number of overloads is true, right? It seems I badly formulated the issue.
I am going to try to change the logic to detect redeclarations the first time such a pair is compared. I've also encountered something strange: when I test with two functions, they are both present in the DeclMap from the first check. With two or more variables, they appear gradually, one by one along the way as if nothing after the current decl is visible. Is this the way the type checker works? This is the reason the issue doesn't apply to variables.
OK, now I see this is a double-edged sword. Some variables may yet not even be part of the AST when 'checkRedeclaration' is invoked, functions are often not type-checked and thus don't have interface types, especially in combinations when the current decl comes earlier than others (a, b). Since we cannot guarantee that everything is type-checked, there is little place for improvement and the function will have to be invoked several times anyways (Everything might finish type-checking only when the last decl in this context is checked by this function).
Still, I can change this to catch redeclarations at (a, b) instead of (b, a), but I am not even sure there will be a use case. Everything that I've tried ends up in 'b' either being not type-checked or not present in lookup results.
Additional Detail from JIRA
md5: e8a0661c20ca16fb283a2301dbe43739
Issue Description:
It is sufficient to check each overload pair in a context once. Currently each function decl is checked subsequently, which results in overload pairs being checked multiple times.
The text was updated successfully, but these errors were encountered: