digitalmars.D.bugs - [Issue 2608] New: int[] literal too polysemous
- d-bugmail puremagic.com (24/24) Jan 23 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2608
- d-bugmail puremagic.com (5/5) Jan 23 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2608
- d-bugmail puremagic.com (6/8) Jan 23 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2608
- d-bugmail puremagic.com (12/12) Jan 23 2009 http://d.puremagic.com/issues/show_bug.cgi?id=2608
- d-bugmail puremagic.com (12/12) Oct 29 2010 http://d.puremagic.com/issues/show_bug.cgi?id=2608
http://d.puremagic.com/issues/show_bug.cgi?id=2608 Summary: int[] literal too polysemous Product: D Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: andrei metalanguage.com The following code fails: void next(T)(ref T[] a) { assert(a.length); a = a[1 .. $]; } void main() { auto a = [ 1, 2, 3 ]; a.next; assert(a == [ 2, 3 ]); } If one replaces "auto" with "int[]", the code compiles and runs as expected. It looks like auto with literals tries too hard to keep it around as an rvalue. This seems to be related to issue 2606. --
Jan 23 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2608 The problem is that an array literal has a static array type by default. Wouldn't it be more user-friendly for it to be a dynamic array type? --
Jan 23 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2608The problem is that an array literal has a static array type by default. Wouldn't it be more user-friendly for it to be a dynamic array type?Oh, you are right. Walter did change the default type of literals to dynamic-length, but apparently only for strings. --
Jan 23 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2608 2korden gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Version|unspecified |2.021 Could you please post generated error message, too, so that other don't have to guess? :) ... a.next; // Error: cast(int[])a is not an lvalue ... --
Jan 23 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2608 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bearophile_hugs eml.cc Resolution| |FIXED That code works with dmd 2.050. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 29 2010