digitalmars.D.bugs - [Issue 14128] New: wrong alias
- via Digitalmars-d-bugs (49/49) Feb 05 2015 https://issues.dlang.org/show_bug.cgi?id=14128
https://issues.dlang.org/show_bug.cgi?id=14128 Issue ID: 14128 Summary: wrong alias Product: D Version: D1 & D2 Hardware: x86_64 OS: Linux Status: NEW Severity: major Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: vlevenfeld gmail.com The line "alias b = that.object" seems to alias this.object: struct TrivialFunctor (T) { T object; int opCmp ()(auto ref TrivialFunctor!T that) { alias a = this.object; alias b = that.object; import std.stdio; writeln (this.object, ` < `, that.object); // 1 < 2 writeln (a, ` < `, b); // 1 < 1 writeln (&(this.object) == &(that.object)); // false, ok writeln (&a == &b); // true?! stdout.flush; if (a < b) return -1; else if (a > b) return 1; else return 0; } auto opBinary (string op)(auto ref TrivialFunctor!T that) { return TrivialFunctor (mixin(q{this.object } ~ op ~ q{ that.object})); } } auto trivial_functor (T)(T value) { return TrivialFunctor!T (value); } void main () { TrivialFunctor!int a = 1.trivial_functor, b = 2.trivial_functor; auto c = a + b; assert (a < b && b < c); // fails } --
Feb 05 2015