Bug 11993 – [REG] typeof(this) in constraint of member function template should reflect method qualifier
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-01-25T08:32:00Z
Last change time
2014-01-27T19:24:47Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
monarchdodra
Comments
Comment #0 by monarchdodra — 2014-01-25T08:32:44Z
This *just* broke on master:
//----
bool fun(T)()
{
pragma(msg, T.stringof);
return true;
}
struct S
{
void foo()() const
if (fun!(typeof(this)))
{}
}
void main()
{
S s;
s.foo();
}
//----
master: "S"
2.064.2: "const(S)"
Here, "foo" is const, so in the template constraint, "this" should be "const(S)". Yet when querying "fun", it prints "S".
This regression is responsible for the failures here:
https://d.puremagic.com/test-results/pull-history.ghtml?projectid=1&repoid=3&pullid=1049
My guess is there is a DMD pull around between 2014-01-23T21:00 and 2014-01-24T21:00 that broke it.
*** Issue 11994 has been marked as a duplicate of this issue. ***
Comment #3 by k.hara.pg — 2014-01-25T09:07:01Z
(In reply to comment #1)
> https://github.com/D-Programming-Language/dmd/pull/3103
>
> Might be responsible for this.
In 2.064 and earlier, there was nasty bug.
bool printType(T, size_t ln = __LINE__)()
{
pragma(msg, T.stringof);
return true;
}
struct S
{
void foo()() const
if (printType!(typeof(this)))
{}
const void bar()()
if (printType!(typeof(this)))
{}
}
void main()
{
S s;
s.foo(); // const(S)
s.bar(); // S
}
When I opened #3103, I didn't know the bug, and to pass existing dmd test case (test/runnable/opover2.d test15()), I was wrongly changed the behavior.
Comment #4 by k.hara.pg — 2014-01-25T09:09:52Z
I change the summary to express the bug more precise that was in 2.064 and earlier.