Bug 500 – Struct Initializers conflict with Delegate Literals in initializers
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-11-13T05:08:00Z
Last change time
2014-02-15T13:20:57Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
marsell_pk
Comments
Comment #0 by marsell_pk — 2006-11-13T05:08:00Z
This compiles:
void delegate() y;
y = { ... };
This does not:
void delegate() y = { ... };
For example:
void main() {
// void delegate() y = { return; };
void delegate() y;
y = { return; };
x(y);
}
void x(void delegate() y) {
y();
}
Comment #1 by bruno.do.medeiros+deebugz — 2006-11-14T07:55:45Z
Not sure it's a bug, that error is because of syntax conflict with struct initializers (http://www.digitalmars.com/d/struct.html). It's a limitation that might or might not be fixable, I dunno. (It does seem possible for the grammar to differentiate
Meanwhile, a workaround:
void delegate() y = ({ return; });
Comment #2 by smjg — 2006-11-14T13:03:29Z
(In reply to comment #1)
> Not sure it's a bug, that error is because of syntax conflict with struct
> initializers (http://www.digitalmars.com/d/struct.html). It's a limitation that
> might or might not be fixable, I dunno. (It does seem possible for the grammar
> to differentiate
The only cases parseable as either a struct init or a function/delegate body are
{ }
{ { } }
{ { { } } }
and so on. Otherwise, it's obvious whether a { ... } contains expressions or statements.
Comment #3 by matti.niemenmaa+dbugzilla — 2006-12-03T03:53:06Z
Fixed in DMD 0.176.
Comment #4 by thomas-dloop — 2006-12-23T15:26:16Z
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[email protected] schrieb am 2006-11-13:
> http://d.puremagic.com/issues/show_bug.cgi?id=500
> This compiles:
> void delegate() y;
> y = { ... };
>
> This does not:
> void delegate() y = { ... };
>
> For example:
> void main() {
> // void delegate() y = { return; };
> void delegate() y;
> y = { return; };
> x(y);
> }
>
> void x(void delegate() y) {
> y();
> }
Added to DStress as
http://dstress.kuehne.cn/run/d/delegate_20_A.dhttp://dstress.kuehne.cn/run/d/delegate_20_B.d
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFFjZaZLK5blCcjpWoRAqsiAJ9/4pC/TdF31L5Ddjgbew7wgEoa9gCfZ6TM
lC/v1sZnTumCoR98ZEI59Rc=
=UG0N
-----END PGP SIGNATURE-----