D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21255 - "overload alias ... forward declaration" when overload set of imported template functions is passed to alias template parameter
Summary: "overload alias ... forward declaration" when overload set of imported templa...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
: 19766 (view as issue list)
Depends on:
Blocks:
 
Reported: 2020-09-16 08:00 UTC by FeepingCreature
Modified: 2021-01-02 20:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description FeepingCreature 2020-09-16 08:00:39 UTC
Consider the following code:

```
--- a.d
void decode()() { }
--- b.d
void decode()() { }
--- test.d
import a : decode;
import b : decode;

void foo(alias A)() { }

void main() { foo!decode; }
```

https://run.dlang.io/is/P00CPB

This results in "Error: overload alias test.decode forward declaration".
Comment 1 FeepingCreature 2020-09-16 08:09:26 UTC
Simpler repro:

```
void decodeA()() { }
void decodeB()() { }

alias decode = decodeA;
alias decode = decodeB;

void foo(alias A)() { }

void main() { foo!decode; }
```

Seems it doesn't know how to mangle overload sets created by alias.
Comment 2 Dlang Bot 2020-09-16 08:38:54 UTC
@FeepingCreature created dlang/dmd pull request #11740 "Fix issue 21255: Mangle aliased overload set passed to template alias parameter." fixing this issue:

- Fix issue 21255: Mangle aliased overload set passed to template alias parameter.

https://github.com/dlang/dmd/pull/11740
Comment 3 Dlang Bot 2020-09-16 10:03:28 UTC
dlang/dmd pull request #11740 "Fix issue 21255: Mangle aliased overload set passed to template alias parameter." was merged into master:

- d6f7073b1dfc7380140a676799a7d430a8e4051a by Mathis Beer:
  Fix issue 21255: Ignore overload declarations when checking for mangling specialcases for template parameters.
  
  The problem is that overload declarations are kind of "fake declarations"
  without many of the properties DMD expects from ordinary declarations. So
  when we try to mangle them, DMD thinks they're "default" linkage, because
  that's LINK.init, and then it errors with "forward declaration" because
  I guess that can't happen normally?
  
  Anyways, there's already code for mangling an overload set; we just have
  to avoid crashing until we reach it.
  
  So now the commit just bypasses the bit that checks for special cases in
  declarations, ie. pragma(mangle) and extern(C).
  
  Why doesn't the handler for Declaration do all this?
  
  ¯\_(ツ)_/¯

https://github.com/dlang/dmd/pull/11740
Comment 4 Boris Carvajal 2021-01-02 20:40:07 UTC
*** Issue 19766 has been marked as a duplicate of this issue. ***