Bug 323006 (MONO80315) - [PATCH] More implicit casts not considered with compound assignments
Summary: [PATCH] More implicit casts not considered with compound assignments
Status: RESOLVED FIXED
Alias: MONO80315
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.2
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Raja R Harinath
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-19 16:45 UTC by Martin Voelkle
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Fix to apply to mcs/mcs/assign.cs. Lacks the check that the selected operator is a predefined operator (468 bytes, patch)
2006-12-19 19:27 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:20:19 UTC


---- Reported by martin.voelkle@gmail.com 2006-12-19 09:45:40 MST ----

Description of Problem:

Weird case not fixed by https://bugzilla.novell.com/show_bug.cgi?id=MONO80313:

using System;

namespace Bugs
{
    class https://bugzilla.novell.com/show_bug.cgi?id=MONO2
    {
        struct MyByte
        {
            private byte value;
            public MyByte(byte value)
            {
                this.value = value;
            }
            public static implicit operator MyByte(byte value)
            {
                return new MyByte(value);
            }
            public static implicit operator byte(MyByte b)
            {
                return b.value;
            }
        }

        public static void Main(string[] args)
        {
            MyByte b = 255;
            b += 255;
            Console.WriteLine(b);
        }
    }
}

Assignment "b += 255" fails although 255 is implicitely
convertible to MyByte.
https://bugzilla.novell.com/show_bug.cgi?id=MONO2.cs(27,13): error CS0031: Constant value `int' cannot be converted to a
`Bugs.https://bugzilla.novell.com/show_bug.cgi?id=MONO2.MyByte'



---- Additional Comments From martin.voelkle@gmail.com 2006-12-19 12:27:54 MST ----

Created an attachment (id=171141)
Fix to apply to mcs/mcs/assign.cs. Lacks the check that the selected operator is a predefined operator




---- Additional Comments From miguel@ximian.com 2007-01-01 04:18:46 MST ----

CCing Marek for his opinion. 



---- Additional Comments From marek.safar@seznam.cz 2007-02-09 19:21:55 MST ----

Sorry for the delay, the patch was applied.

Thanks for the effort.

Imported an attachment (id=171141)

Unknown operating system unknown. Setting to default OS "Other".