www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8807] New: Better error messages for a switch on doubles

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8807

           Summary: Better error messages for a switch on doubles
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



From the thread:
http://forum.dlang.org/thread/osnevnwnshreoaudleep forum.dlang.org


void main() {
     double value = 1;
     switch (value) {
       case 1:
         // do something
         break;
       default:
     }
}


DMD 2.061alpha gives:

temp2.d(3): Error: 'value' is not of integral type, it is a double
temp2.d(4): Error: case must be a string or an integral constant, not 1

The error messages are not so good:
- The first error message misses the possibility of a switch on strings.
- The second error message is just wrong, because 1 is on default an integral
constant.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 12 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8807


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



15:50:45 PST ---

 temp2.d(3): Error: 'value' is not of integral type, it is a double
This is solved in pull for Issue 4540.
 temp2.d(4): Error: case must be a string or an integral constant, not 1
 - The second error message is just wrong, because 1 is on default an integral
 constant.
It's not actually wrong, 1 is implicitly converted to type double. Unfortunately it doesn't print 1.0 to make it obvious. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8807


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
           Platform|x86                         |All
         AssignedTo|nobody puremagic.com        |andrej.mitrovich gmail.com
         OS/Version|Windows                     |All



19:59:16 PST ---
https://github.com/D-Programming-Language/dmd/pull/1514

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 19 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8807


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME



10:00:49 PST ---

 https://github.com/D-Programming-Language/dmd/pull/1514
as '1' because it's a more general problem unrelated to the switch statement. http://d.puremagic.com/issues/show_bug.cgi?id=9357 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 20 2013