www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10989] New: [CTFE] Uncaught exception messages are not pretty printed if message wasn't literal

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

           Summary: [CTFE] Uncaught exception messages are not pretty
                    printed if message wasn't literal
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: dmitry.olsh gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh gmail.com> 2013-09-07
15:40:59 PDT ---
import std.string;

enum foo = (){ 
    throw new Exception(format("Something %d wicked happened!", 42));
    return 0;
}();

On a recent DMD from git master:

D:\D\ctfe_ex.d(4): Error: Uncaught CTFE exception object.Exception(['S', 'o',
'm', 'e', 't', 'h', 'i', 'n', 'g', ' ', '4', '2', ' ', 'w', 'i', 'c', 'k', 'e',
'd', ' ', 'h', 'a', 'p', 'p', 'e', 'n', 'e', 'd', '!'][0u..29u])
D:\D\ctfe_ex.d(6):        called from here: (*int()

{

throw new Exception(format("Something %d wicked happened!", 42),
"D:\\D\\ctfe_ex.d", 4u, null);

return 0;

}

Note that the following using plain literal neatly formats the string:

enum foo = (){ 
    throw new Exception("Something wicked happened!");
    return 0;
}();

D:\D\ctfe_ex.d(2): Error: Uncaught CTFE exception object.Exception("Something
wicked happened!")

The point is it should always pretty print it unless it contains bad UTF-8.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 07 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10989



--- Comment #1 from Don <clugdbug yahoo.com.au> 2013-09-10 23:23:00 PDT ---
Patch:

--- a/src/ctfeexpr.c
+++ b/src/ctfeexpr.c
   -157,7 +157,7    char *ThrownExceptionExp::toChars()
 void ThrownExceptionExp::generateUncaughtError()
 {
     thrown->error("Uncaught CTFE exception %s(%s)", thrown->type->toChars(),
-        (*thrown->value->elements)[0]->toChars());
+        (*thrown->value->elements)[0]->toString()->toChars());
     /* Also give the line where the throw statement was. We won't have it
      * in the case where the ThrowStatement is generated inter


Reduced test case:

enum foo = () { throw new Exception(['a', 'b', 'c']); return 0; }();

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



--- Comment #2 from Don <clugdbug yahoo.com.au> 2013-09-16 00:56:33 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2563

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



--- Comment #3 from github-bugzilla puremagic.com 2013-09-16 15:44:16 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/8779d47334e6b1f7cfab13a8955cdceb733d403a
Fix bug 10989 [CTFE] Uncaught exception messages are not pretty printed

Convert it to a StringExp before printing.

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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