39 – ArrayMemberInitialization, StructMemberInitializer inconsistencies from dmd's behavior

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 39 - ArrayMemberInitialization, StructMemberInitializer inconsistencies from dmd's behavior
Summary: ArrayMemberInitialization, StructMemberInitializer inconsistencies from dmd's...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D1 (retired)
Hardware: PowerPC Mac OS X
: P2 normal
Assignee: Walter Bright
URL: http://www.digitalmars.com/d/declarat...
Keywords: spec
Depends on:
Blocks: 677
Show dependency tree / graph
Reported: 2006年03月12日 12:58 UTC by Brad Roberts
Modified: 2014年02月15日 02:15 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Brad Roberts 2006年03月12日 12:58:55 UTC
Currently, the spec describes ArrayMemberInitialization so:
ArrayMemberInitialization:
 AssignExpression
 AssignExpression : AssignExpression
However, considering the following:
struct test
{
 int i;
}
static test[] tests = [
 {1},
];
Compiles just fine, I believe the spec to be incorrect. Instead, it might be:
ArrayMemberInitialization:
 AssignExpression
 AssignExpression : AssignExpression
 StructInitializer
 AssignExpression : StructInitializer
 ArrayInitializer
 AssignExpression : ArrayInitializer
That said, this compiles too:
struct test
{
 int[] i;
}
static test tests = {
 [1, 2, 3]
};
So it might seem that StructMemberInitializer would need the reverse change, becoming:
StructMemberInitializer:
 AssignExpression
 Identifier : AssignExpression
 ArrayInitializer
 Identifier : ArrayInitializer
 StructInitializer
 Identifier : StructInitializer
Comment 1 Stewart Gordon 2006年07月19日 09:26:57 UTC
Indeed, ctod.html has an example of array initialisers nested within each other. So obviously, the documented ArrayMemberInitialization syntax is inaccurate.
Moreover, why not make it a little simpler:
 ArrayMemberInitialization:
 Initializer
 AssignExpression : Initializer
 StructMemberInitialization: // let's make the naming consistent
 Initializer
 Identifier : Initializer
Comment 2 Walter Bright 2006年12月27日 01:57:30 UTC
Fixed DMD 0.178


AltStyle によって変換されたページ (->オリジナル) /