Bug 1356 – Some parsing issues with struct initializers.

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2007-07-20T15:39:00Z
Last change time
2014-02-16T15:21:24Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
aziz.koeksal

Comments

Comment #0 by aziz.koeksal — 2007-07-20T15:39:14Z
struct foo { int a = 4; } static foo f = {a:void,}; // Void initializer allowed in struct initializer. writefln(f.a); // prints 0 // Struct initializer can have any number of leading and trailing commas, whereas only a trailing one is allowed. static foo f = {,,,,a:1,,,,}; // Compiler hangs if this is at the end of a file. static foo f = {
Comment #1 by clugdbug — 2011-12-22T00:59:59Z
(In reply to comment #0) > struct foo { int a = 4; } > > static foo f = {a:void,}; // Void initializer allowed in struct initializer. > writefln(f.a); // prints 0 This isn't a bug. > > // Struct initializer can have any number of leading and trailing commas, > whereas only a trailing one is allowed. > static foo f = {,,,,a:1,,,,}; Fixed in 2.055 and 1.070. > > // Compiler hangs if this is at the end of a file. > static foo f = { Fixed in 1.023.