Bug 14406 – [REG2.068a] GIT HEAD ignores forward reference and generates wrong code
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-04-05T01:11:00Z
Last change time
2015-06-17T21:04:20Z
Keywords
accepts-invalid, pull, wrong-code
Assigned to
nobody
Creator
puneet
Comments
Comment #0 by puneet — 2015-04-05T01:11:42Z
Reduced test.
// assertion fails -- both bar_obj and foo should be null though
class Foo {}
string str_mixin(T)() {
alias P = Poo!T;
return "Bar bar_obj;
static class Bar { Foo foo; }";
}
template Poo(T) {
static if(T.tupleof.length) {};
}
class Frop {
mixin(str_mixin!(typeof(this)));
}
void main() {
Frop simple = new Frop;
assert(simple.bar_obj.foo is null, "foo is not null");
}
Comment #1 by puneet — 2015-04-05T01:13:41Z
2.067-rc1 does not compile the code. Regression only for GIT HEAD.
Comment #2 by k.hara.pg — 2015-04-05T03:20:59Z
This is an accepts-invalid bug. Slightly reduced:
class Foo {}
string str_mixin(T)()
{
static if (T.tupleof.length) {} // Fix instance size of T (== Frop)
return "Bar bar_obj; static class Bar { Foo foo; }";
}
class Frop
{
mixin(str_mixin!(typeof(this))); // adding more field after Frop fields fixed.
}
void main()
{
Frop simple = new Frop;
}
In str_mixin() function, testing Frop.tupleof fix the class fields and instance size. Therefore adding one more field `bar_obj` should be rejected because it will change the Frop instance size.