Bug 1030 – Delegate literal as initializer is confused with struct initializer
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-03-07T13:20:00Z
Last change time
2014-04-18T09:12:04Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
default_357-line
Comments
Comment #0 by default_357-line — 2007-03-07T13:20:34Z
The following one-liner causes an ICE in line 0. Verified on GDC .21, .23 and DMD 1.007:
void main() { void delegate() test={ struct test2 {;} }; }
Greetings, downs
This is really a totally different bug to the original one, and much less severe. No longer an ICE -- it's a pretty tiny issue.
void main() {
void delegate() test = {
struct test2{}
}
}
---
fog.d(4): expression expected, not 'struct'
fog.d(4): comma expected separating field initializers
fog.d(5): semicolon expected, not '}'
----
Comment #7 by smjg — 2009-04-19T07:29:13Z
> fog.d(5): semicolon expected, not '}'
This last message is the one that's correct. A declaration of a variable (which is what test is) always requires a closing semicolon.
What's actually happening is that it's trying to parse
{ struct test2{} }
as a struct initializer. Nothing to do with the struct that's actually declared inside. See for yourself:
----------
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>type bz1030a.d
void main() {
void delegate() test = {
struct test2{}
};
}
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd bz1030a.d
bz1030a.d(4): expression expected, not 'struct'
bz1030a.d(4): comma expected separating field initializers
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>type bz1030b.d
void main() {
void delegate() test;
test = {
struct test2{}
};
}
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>dmd bz1030b.d
C:\Users\Stewart\Documents\Programming\D\Tests\bugs>
----------
Since AIUI there's no overlap between what's parseable as a struct init and what's parseable as a delegate literal, there should be little or no problem getting it to work.
Comment #8 by clugdbug — 2009-09-15T06:36:54Z
This remaining bug is not a regression. It behaved exactly the same way in DMD0.175.
Another of these annoying cases where we have two unrelated bugs in the same report. It should not have been reopened.
Comment #9 by clugdbug — 2010-01-18T06:38:18Z
The original bug was fixed in 1.009. The bug reported in the comments is the same as bug 1371; I'm therefore closing this one.