Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 12, 2007 [Issue 1727] New: Associate Array Literals regression | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=1727 Summary: Associate Array Literals regression Product: D Version: 2.008 Platform: PC OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: davidl@126.com Following does not compile: int[char[]] ca= [cast(char[])"asdf":1,cast(char[])"asdf1":2]; -- |
December 12, 2007 [Issue 1727] Associate Array Literals regression | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1727 davidl@126.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |major Priority|P2 |P1 ------- Comment #1 from davidl@126.com 2007-12-11 23:28 ------- It's blocking my code from porting to D2.0. So I mark this at a little higher priority . -- |
December 12, 2007 Re: [Issue 1727] New: Associate Array Literals regression | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=1727
>
> Summary: Associate Array Literals regression
> Following does not compile:
> int[char[]] ca= [cast(char[])"asdf":1,cast(char[])"asdf1":2];
When did this ever compile? I think this is an unimplemented feature, not a regression.
|
December 12, 2007 Re: [Issue 1727] New: Associate Array Literals regression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | "Don Clugston" <dac@nospam.com.au> wrote in message news:fjoue2$o1o$1@digitalmars.com... > d-bugmail@puremagic.com wrote: >> http://d.puremagic.com/issues/show_bug.cgi?id=1727 >> >> Summary: Associate Array Literals regression >> Following does not compile: >> int[char[]] ca= [cast(char[])"asdf":1,cast(char[])"asdf1":2]; > > When did this ever compile? I think this is an unimplemented feature, not a regression. > Uh, are you talking about AA literals? They've been in D since 1.014 (April 26).. this code works with D1. |
December 12, 2007 Re: [Issue 1727] New: Associate Array Literals regression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: > "Don Clugston" <dac@nospam.com.au> wrote in message news:fjoue2$o1o$1@digitalmars.com... >> d-bugmail@puremagic.com wrote: >>> http://d.puremagic.com/issues/show_bug.cgi?id=1727 >>> >>> Summary: Associate Array Literals regression >>> Following does not compile: >>> int[char[]] ca= [cast(char[])"asdf":1,cast(char[])"asdf1":2]; >> When did this ever compile? I think this is an unimplemented feature, not a regression. >> > > Uh, are you talking about AA literals? They've been in D since 1.014 (April 26).. this code works with D1. It won't compile at global scope, and never has. http://www.digitalmars.com/d/1.0/expression.html#AssocArrayLiteral "An AssocArrayLiteral cannot be used to statically initialize anything." -- E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi |
December 12, 2007 Re: [Issue 1727] New: Associate Array Literals regression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matti Niemenmaa | "Matti Niemenmaa" <see_signature@for.real.address> wrote in message news:fjpbvo$1s6a$1@digitalmars.com... > > It won't compile at global scope, and never has. > > http://www.digitalmars.com/d/1.0/expression.html#AssocArrayLiteral > > "An AssocArrayLiteral cannot be used to statically initialize anything." Then it's not a bug in any way, is it? It's stupid, but according to spec. And it's not a regression because nothing changed. It works fine in 2.008 too. |
December 12, 2007 Re: [Issue 1727] New: Associate Array Literals regression | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: > "Matti Niemenmaa" <see_signature@for.real.address> wrote in message news:fjpbvo$1s6a$1@digitalmars.com... >> It won't compile at global scope, and never has. >> >> http://www.digitalmars.com/d/1.0/expression.html#AssocArrayLiteral >> >> "An AssocArrayLiteral cannot be used to statically initialize anything." > > Then it's not a bug in any way, is it? It's stupid, but according to spec. And it's not a regression because nothing changed. It works fine in 2.008 too. I don't have a 2.0 installation handy so I don't know, but yes: if it works fine when doing the initialization in a static constructor, for instance, then it's not a bug. -- E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi |
December 13, 2007 [Issue 1727] Associate Array Literals regression | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1727 davidl@126.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|major |regression ------- Comment #3 from davidl@126.com 2007-12-13 02:20 ------- Oh, you remind me that the severity is regression. It compiles by D1.X compilers. And spec gives a simplest example with same length string literals If I remember correctly: int[char[]] aa=["aa":1,"bb":2,"cc":3]; -- |
December 13, 2007 [Issue 1727] Associate Array Literals regression | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1727 matti.niemenmaa+dbugzilla@iki.fi changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #4 from matti.niemenmaa+dbugzilla@iki.fi 2007-12-13 04:40 ------- It has never compiled, neither in 1.0 nor in 2.0. http://www.digitalmars.com/d/expression.html#AssocArrayLiteral gives the example "[21u:"he",38:"ho",2:"hi"];" but doesn't assign it to anything. It also says "[a]n AssocArrayLiteral cannot be used to statically initialize anything." This means that code of the form "<associative array type> foo = <associative array literal>" doesn't work, nor has it ever. Unless code like the following fails, this is an invalid bug: int[char[]] a; static this() { a = ["aa":1,"bb":2,"cc":3]; } -- |
December 13, 2007 [Issue 1727] Associate Array Literals regression | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=1727 gide@nwawudu.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | ------- Comment #5 from gide@nwawudu.com 2007-12-13 13:15 ------- The following code compiles on both GDC and DMD, but DMD compiled code throws an array bounds exception when executed. I think DMD might have a bug. test.d ------ import std.stdio; void main() { int[char[]] aa = ["aa":1, "bb":2, "cc":3]; // Fails //int[char[]] aa; aa = ["aa":1, "bb":2, "cc":3]; // Fails //int[char[]] aa; aa["aa"] = 1; aa["bb"] = 2; aa["cc"] = 3; // OK assert(aa.length == 3); assert(aa["aa"]==1); // Fails on DMD 2.008. Error: ArrayBoundsError test(8) assert(aa["bb"]==2); assert(aa["cc"]==3); writefln(aa["aa"],aa["bb"],aa["cc"]); // On GDC outputs: 123 } -- |
Copyright © 1999-2021 by the D Language Foundation