Bug 15784 – Overload set constructor call should be supported from inside a constructor

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-03-10T14:50:00Z
Last change time
2016-03-14T19:45:53Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg
Depends on
15744

Comments

Comment #0 by k.hara.pg — 2016-03-10T14:50:45Z
From issue 15744 test case: template AddField(T) { T b; this(Args...)(T b, auto ref Args args) { this.b = b; //this(args); // not OK (segfaults, issue 15744) } } template construcotrs() { int a; this(int a) { this.a = a; } } struct Bar { mixin construcotrs; mixin AddField!(string); } void main() { auto bar1 = Bar(5); // OK auto bar2 = Bar("bar", 15); // also OK } In main, outside of construction functions, the Bar's overload set constructor (declared in AddField and constructors mixin template) called is accepted. But from inside the constructor AddField.this(Args...)(T b, auto ref Args args), a constructor call this(args); cannot work. it's merely inconsistent behavior, and should be treated as a rejects-valid bug.
Comment #1 by code — 2016-03-11T21:15:43Z
Why isn't this working? The lookup origin should already be Bar. Note that you should still only be allowed to match a single member of an overload set.
Comment #2 by k.hara.pg — 2016-03-14T15:34:47Z
https://github.com/D-Programming-Language/dmd/pull/5524(In reply to Martin Nowak from comment #1) > Why isn't this working? The lookup origin should already be Bar. > Note that you should still only be allowed to match a single member of an > overload set. Because the call forms `super(...)` and `this(...)` are specially handled in CallExp.semantic(), and they didn't consider the case that the construcotor is OverloadSet. Fix: https://github.com/D-Programming-Language/dmd/pull/5524
Comment #3 by github-bugzilla — 2016-03-14T19:45:52Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/c52dc4733fd2cba284d8b8ff35bcf4e39ba7ebcd fix Issue 15784 - Overload set constructor call should be supported from inside a constructor https://github.com/D-Programming-Language/dmd/commit/4b632c1e10031918c36022a39cca289cc1ba2345 Merge pull request #5524 from 9rnsr/fix15784 Issue 15784 - Overload set constructor call should be supported from inside a constructor