D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 17130 - [Reg 2.074] ambiguous implicit super call when inheriting core.sync.mutex.Mutex
Summary: [Reg 2.074] ambiguous implicit super call when inheriting core.sync.mutex.Mutex
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: druntime (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2017-01-30 16:47 UTC by Martin Nowak
Modified: 2017-03-22 12:21 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Martin Nowak 2017-01-30 16:47:40 UTC
cat > bug.d << CODE
import core.sync.mutex : Mutex;

class MyMutex : Mutex
{
}
CODE

dmd -c -o- bug

----
/home/dawg/Code/D/bug.d(3): Error: core.sync.mutex.Mutex.__ctor called with argument types () matches both:
/home/dawg/dlang/dmd-master-2017-01-28/linux/bin64/../../src/druntime/import/core/sync/mutex.di(21):     core.sync.mutex.Mutex.this()
and:
/home/dawg/dlang/dmd-master-2017-01-28/linux/bin64/../../src/druntime/import/core/sync/mutex.di(25):     core.sync.mutex.Mutex.this()
/home/dawg/Code/D/bug.d(3): Error: class bug.MyMutex cannot implicitly generate a default ctor when base class core.sync.mutex.Mutex is missing a default ctor
----

Introduced by https://github.com/dlang/druntime/issues/1728 or https://github.com/dlang/druntime/issues/1726.

This is arguable a dmd bug, but it easily breaks any Mutex sub-class right now.
Comment 1 Martin Nowak 2017-01-30 17:04:55 UTC
Currently breaks vibe.d and a couple of projects on ci.dawg.eu.
Comment 2 ZombineDev 2017-01-31 16:24:06 UTC
This indeed looks like a compiler bug. If the base class has multiple default constructors, the compiler should synthesize multiple default constructors in the derived class. I.e. the base class and the derived class should have equivalent default constructor overload sets.

BTW, the code in question can be easily be worked around like this:
class MyMutex : Mutex
{
    this()
    {
        super();
    }
}

Though the following did not work:
class MyMutex : Mutex
{
    this()
    {
    }
}

Error: core.sync.mutex.Mutex.__ctor called with argument types () matches both:
druntime/import/core/sync/mutex.di(21):     core.sync.mutex.Mutex.this()
and:
druntime/import/core/sync/mutex.di(25):     core.sync.mutex.Mutex.this()
bug.d(5):
Comment 3 Martin Nowak 2017-02-01 14:29:16 UTC
I'll have a look at fixing the compiler implementation later today.
Comment 4 Martin Nowak 2017-02-03 16:57:29 UTC
https://github.com/dlang/dmd/pull/6513
Comment 5 github-bugzilla 2017-02-10 15:35:18 UTC
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/db81df0b6db19f5808e551a01730c15d341dc981
fix Issue 17130 - ambiguous implicit super call

- need type of this to resolve base class ctor overloads

https://github.com/dlang/dmd/commit/5262d78df2d2b4b3ee1fffc3393a5d57b535a481
Merge pull request #6513 from MartinNowak/fix17130

fix Issue 17130 - ambiguous implicit super call
Comment 6 ZombineDev 2017-02-12 15:04:53 UTC
Reopening because even though this was fixed:
class MyMutex : Mutex
{
    this() // OK after https://github.com/dlang/dmd/pull/6513
    {
    }
}

the OP issue is still there:
class MyMutex : Mutex
{
     // NG
}

bug.d(3): Error: core.sync.mutex.Mutex.__ctor called with argument types () matches both:
/home/zombinedev/code/repos/dlang/druntime/import/core/sync/mutex.di(21):     core.sync.mutex.Mutex.this()
and:
/home/zombinedev/code/repos/dlang/druntime/import/core/sync/mutex.di(25):     core.sync.mutex.Mutex.this()
bug.d(3): Error: class mutex_attr.MyMutex cannot implicitly generate a default ctor when base class core.sync.mutex.Mutex is missing a default ctor
Comment 7 Martin Nowak 2017-02-14 11:38:45 UTC
https://github.com/dlang/dmd/pull/6541
Comment 8 github-bugzilla 2017-02-15 12:31:49 UTC
Commits pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/cfeb41ae8db207d708b48155760a52dba0c57791
fix Issue 17130 - ambiguous implicit super call

- need to pass class type to resolveFuncCall
- also make implicit ctor shared for shared base ctor

https://github.com/dlang/dmd/commit/69182dac5d7e4ba0f32377715f24ccf910d2f333
Merge pull request #6541 from MartinNowak/fix17130

fix Issue 17130 - ambiguous implicit super call
Comment 9 github-bugzilla 2017-02-24 20:34:32 UTC
Commits pushed to newCTFE at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/db81df0b6db19f5808e551a01730c15d341dc981
fix Issue 17130 - ambiguous implicit super call

https://github.com/dlang/dmd/commit/5262d78df2d2b4b3ee1fffc3393a5d57b535a481
Merge pull request #6513 from MartinNowak/fix17130

https://github.com/dlang/dmd/commit/cfeb41ae8db207d708b48155760a52dba0c57791
fix Issue 17130 - ambiguous implicit super call

https://github.com/dlang/dmd/commit/69182dac5d7e4ba0f32377715f24ccf910d2f333
Merge pull request #6541 from MartinNowak/fix17130
Comment 10 github-bugzilla 2017-03-22 12:21:29 UTC
Commits pushed to stable at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/db81df0b6db19f5808e551a01730c15d341dc981
fix Issue 17130 - ambiguous implicit super call

https://github.com/dlang/dmd/commit/5262d78df2d2b4b3ee1fffc3393a5d57b535a481
Merge pull request #6513 from MartinNowak/fix17130

https://github.com/dlang/dmd/commit/cfeb41ae8db207d708b48155760a52dba0c57791
fix Issue 17130 - ambiguous implicit super call

https://github.com/dlang/dmd/commit/69182dac5d7e4ba0f32377715f24ccf910d2f333
Merge pull request #6541 from MartinNowak/fix17130