Bug 14141 – `pure` member function returning qualified member result is implicitly convertible to unqualified

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-02-07T16:25:00Z
Last change time
2015-02-21T09:11:15Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2015-02-07T16:25:12Z
This code should compile: --- struct S { Object obj; const(Object) getObj() const pure { return obj; } } void main() { const S s; static assert(is(typeof(s.getObj()) == const Object)); // ok static assert(!__traits(compiles, { Object o = s.getObj(); })); // fails } --- As a result such function compiles but shouldn't: --- Object f(const Object o) { const S s = { obj: o }; return s.getObj(); } --- This results in type system breakage.
Comment #1 by k.hara.pg — 2015-02-09T13:34:38Z
*** This issue has been marked as a duplicate of issue 14155 ***
Comment #2 by github-bugzilla — 2015-02-11T23:23:41Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f42159ac11325fcfa61134feef2da6ae9701b6e4 fix Issue 14141 - `pure` member function returning qualified member result is implicitly convertible to unqualified
Comment #3 by github-bugzilla — 2015-02-21T09:11:15Z
Commit pushed to https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f42159ac11325fcfa61134feef2da6ae9701b6e4 fix Issue 14141 - `pure` member function returning qualified member result is implicitly convertible to unqualified