Bug 21505 – Function alias reported as conflicting function
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-12-26T17:21:18Z
Last change time
2021-02-13T12:29:54Z
Keywords
pull
Assigned to
No Owner
Creator
moonlightsentinel
Comments
Comment #0 by moonlightsentinel — 2020-12-26T17:21:18Z
Consider the following code:
=====================================
void bar (int s) {}
void foo (int s) {}
alias bar = foo;
void main ()
{
bar(0);
}
=====================================
Before:
test.d(7): Error: test.foo called with argument types (int) matches both:
test.d(1): test.foo(int s)
and:
test.d(2): test.bar(int s)
Now:
test.d(2): Error: function test.bar(int s) conflicts with previous declaration at test.d(1)
Introduced by https://github.com/dlang/dmd/pull/8429
Comment #1 by dlang-bot — 2021-01-28T20:37:48Z
@MoonlightSentinel updated dlang/dmd pull request #12053 "Fix duplicate function detection for overloads introduced by aliases" fixing this issue:
- Fix 21505 - Rework duplicate function detection without mangling
The previous implementation compared small parts of the function mangling
to detect duplicate functions. This approach had several flaws manifesting
in the referenced issue as well as other false positives for (static)
members, `alias`ing into different scopes, ... .
Issue 21505 was caused by the assumption that all functions visited by
`overloadApply` have the same name. This doesn't hold for overloads
introduced by an `alias`.
A reliable mangling-based implementation would need to compare most of
the mangled name while also omitting severel aspects e.g. the return type
to detect `int foo()` and `void foo()`.
Hence the current implementation was replaced by actually comparing the
`FuncDeclaration`s because it allows for more fine grained checks (and
also should save some memory allocations).
https://github.com/dlang/dmd/pull/12053
Comment #2 by dlang-bot — 2021-01-31T09:10:06Z
dlang/dmd pull request #12053 "Fix duplicate function detection for overloads introduced by aliases" was merged into stable:
- 487e32082ebe51abee747200e4071b4f58b35957 by MoonlightSentinel:
Fix 21505 - Rework duplicate function detection without mangling
The previous implementation compared small parts of the function mangling
to detect duplicate functions. This approach had several flaws manifesting
in the referenced issue as well as other false positives for (static)
members, `alias`ing into different scopes, ... .
Issue 21505 was caused by the assumption that all functions visited by
`overloadApply` have the same name. This doesn't hold for overloads
introduced by an `alias`.
A reliable mangling-based implementation would need to compare most of
the mangled name while also omitting severel aspects e.g. the return type
to detect `int foo()` and `void foo()`.
Hence the current implementation was replaced by actually comparing the
`FuncDeclaration`s because it allows for more fine grained checks (and
also should save some memory allocations).
https://github.com/dlang/dmd/pull/12053
Comment #3 by dlang-bot — 2021-02-13T12:29:54Z
dlang/dmd pull request #12195 "Merge stable" was merged into master:
- 41fa5138bc8aebcf9ab4870c4df19e42e1f97d80 by Florian:
Fix 21505 - Rework duplicate function detection without mangling (#12053)
The previous implementation compared small parts of the function mangling
to detect duplicate functions. This approach had several flaws manifesting
in the referenced issue as well as other false positives for (static)
members, `alias`ing into different scopes, ... .
Issue 21505 was caused by the assumption that all functions visited by
`overloadApply` have the same name. This doesn't hold for overloads
introduced by an `alias`.
A reliable mangling-based implementation would need to compare most of
the mangled name while also omitting severel aspects e.g. the return type
to detect `int foo()` and `void foo()`.
Hence the current implementation was replaced by actually comparing the
`FuncDeclaration`s because it allows for more fine grained checks (and
also should save some memory allocations).
https://github.com/dlang/dmd/pull/12195