Bug 2808 – 'nothrow' nested functions cannot be parsed

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-04-06T08:10:00Z
Last change time
2015-06-09T01:18:04Z
Keywords
patch, rejects-valid
Assigned to
bugzilla
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2009-04-06T08:10:25Z
nothrow void foo(){ void bar1() nothrow {} // ok nothrow void bar2() {} // fails bar1(); } --- bug.d(3): found 'nothrow' instead of statement bug.d(4): no identifier for declarator bar1 bug.d(5): unrecognized declaration
Comment #1 by clugdbug — 2009-04-06T14:06:10Z
I can make this work by changing parse.c line 3200. It surprises me that this is in Parser::parseStatement; but since it's in the label "Ldeclaration", I believe it is correct. It means that code like "nothrow int x=7;" is accepted, but that's accepted at global scope already. So I don't think there's anything wrong with this patch. #if DMDV2 case TOKimmutable: case TOKshared: case TOKnothrow: // add this line #endif // case TOKtypeof: Ldeclaration:
Comment #2 by bugzilla — 2009-04-11T00:12:40Z
It needs a TOKpure added as well.
Comment #3 by clugdbug — 2009-04-12T23:19:39Z
(In reply to comment #2) > It needs a TOKpure added as well. I'm not sure that you want to allow 'pure' on nested functions at all, because of bug 2807. If it is allowed, a pure nested function needs to treat all of the variables in the parent function as if they were globals.
Comment #4 by clugdbug — 2009-05-07T03:04:42Z
Fixed DMD2.029