[Issue 1030] Delegate literal as initializer is confused with struct initializer
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 19 05:29:06 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1030
smjg at iname.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|struct in delegate requires |Delegate literal as
|semicolon |initializer is confused with
| |struct initializer
Version|unspecified |1.041
------- Comment #7 from smjg at iname.com 2009-04-19 07:29 -------
> 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.
--
More information about the Digitalmars-d-bugs
mailing list