[Issue 3050] New: Allow exception in CTFE (patch)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 3 21:05:11 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3050
Summary: Allow exception in CTFE (patch)
Product: D
Version: 2.030
Platform: x86
OS/Version: All
Status: NEW
Keywords: patch
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: rsinfu at gmail.com
Created an attachment (id=389)
--> (http://d.puremagic.com/issues/attachment.cgi?id=389)
Patch (DMD 2.030)
The proposed patch implements support for throw/try/catch/finally in CTFE.
Throw statement is, however, somewhat limited; new expression is not allowed,
except for new Exception("msg").
Example and output:
--------------------
int thrower(string s)
{
// The interpretor emulates throw new Exception("msg")
throw new Exception("exception " ~ s);
return 0;
}
int catcher()
{
try
{
return thrower("abc");
}
catch (Exception e)
{
throw e;
}
return 0;
}
enum a = catcher("abc");
--------------------
test.d(21): Error: uncaught exception from catcher(): "exception abc"
test.d(21): Error: cannot evaluate catcher() at compile time
--------------------
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list