November 13, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=10962


yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com


--- Comment #1 from yebblies <yebblies@gmail.com> 2013-11-13 16:13:11 EST ---
Because E.init has type E and e1 has type const(E), it misses the t1->equals(t2) condition in CondExp::semantic, and goes to typeMerge, which calls toBaseType on both, giving short, which it then promotes to int.

CondExp::semantic and/or typeMerge need to be fixed to prefer const conversion over promotion.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 22, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=10962


Denis Shelomovskij <verylonglogin.reg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg@gmail.com
            Summary|Wrong implicit conversion   |Incorrect merging of same
                   |of enum in const function   |enum types with different
                   |                            |qualifiers


--- Comment #2 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2013-12-22 12:53:52 MSK ---
Reduced testcase (the issue has nothing to do with `const` functions):

This code should compile:
---
enum E { a }

void main()
{
    const E ce;
    auto x = 1 ? ce : E.a;
    E e = x;                                 // line 7
    static assert(is(typeof(x) == const E)); // line 8
}
---
main.d(7): Error: cannot implicitly convert expression (x) of type int to E
main.d(8): Error: static assert  (is(int == const(E))) is false
---

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------