digitalmars.D.bugs - [Issue 5396] New: Invalid code with nested functions in CTFE
- d-bugmail puremagic.com (36/36) Jan 01 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5396
- d-bugmail puremagic.com (42/42) May 24 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5396
- d-bugmail puremagic.com (13/13) Jun 23 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5396
http://d.puremagic.com/issues/show_bug.cgi?id=5396 Summary: Invalid code with nested functions in CTFE Product: D Version: D1 & D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: robert octarineparrot.com --- Comment #0 from Robert Clipsham <robert octarineparrot.com> 2011-01-01 18:54:57 GMT --- The following code: ---- void outer(bool b) { string inner() { if (b) { return "true"; } else { return "false"; } } pragma(msg, inner()); } ---- Compiles and evaluates without error, despite the dependence on the runtime value b. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 01 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5396 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au --- Comment #1 from Don <clugdbug yahoo.com.au> 2011-05-24 21:40:59 PDT --- Extended test cases (applies to delegate literals as well as inner functions): void bug5396(int b) { int inner() { return b; } static int staticInner() { return 6; } static assert(is(typeof(compiles!( function int () { return 7; }() )))); static assert(!is(typeof(compiles!( delegate int () { return b; }() )))); static assert(!is(typeof(compiles!( inner() )))); static assert(is(typeof(compiles!( staticInner() )))); } Patch in interpret.c, CallExp::interpret(). Problem is, this breaks bug 1461 which seems to be an important use case. if (!istate && fd && fd->isNested() && !fd->isStatic() && /* BUG: Delegate literals report 'isNested()' even if they are * declared at module scope. */ !(fd->isFuncLiteralDeclaration() && !fd->toParent2()->isFuncDeclaration())) { error("cannot directly interpret non-static nested function %s", fd->toChars()); return EXP_CANT_INTERPRET; } if (pthis && fd) { // Member function call -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 24 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5396 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Summary|Invalid code with nested |[CTFE] Invalid code with |functions in CTFE |nested functions in CTFE --- Comment #2 from Don <clugdbug yahoo.com.au> 2011-06-23 00:33:12 PDT --- https://github.com/D-Programming-Language/dmd/commit/04460186c70caa885935433138879d8684b1d14a -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 23 2011