digitalmars.D.bugs - [Issue 5290] New: Static array literals with too few elements
- d-bugmail puremagic.com (23/23) Nov 29 2010 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (10/10) Sep 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (11/12) Sep 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (6/6) Sep 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (12/13) Sep 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (8/11) Sep 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (15/17) Sep 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (10/16) Sep 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (7/7) Sep 09 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (12/18) Jan 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (7/18) Jan 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (18/18) Jan 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5290
- d-bugmail puremagic.com (11/25) Jan 24 2012 http://d.puremagic.com/issues/show_bug.cgi?id=5290
http://d.puremagic.com/issues/show_bug.cgi?id=5290 Summary: Static array literals with too few elements Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: dsimcha yahoo.com The following invalid code is accepted: import std.stdio; void main() { real[2] foo = [1.0L]; writeln(foo); // [1, 0] } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 29 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5290 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch https://github.com/D-Programming-Language/dmd/pull/375 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5290 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cchttps://github.com/D-Programming-Language/dmd/pull/375Pull 375 is not about bug 3849 too, right? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5290 Pull 375 does not support `int[$] = [1, 2, 3];`. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5290Pull 375 does not support `int[$] = [1, 2, 3];`.OK. This is expected. Currenly DMD runs code like this (I don't like this, but this is working as designed!): int[3] arr = [1, 2]; void main() {} I presume Pull 375 lets this kind of code pass, right? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5290int[3] arr = [1, 2]; void main() {} I presume Pull 375 lets this kind of code pass, right???? Pull 375 rejects statically above code, it is expected behavior from this issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5290??? Pull 375 rejects statically above code, it is expected behavior from this issue.I see. I suggest you to read the whole thread of bug 3849. Code like the following is working as designed, so if your patch refuses this code, then your patch is implementing an enhancement too (it means it's changing the D specs): int[3] arr = [1, 2]; void main() {} Note that I support turning this kind of code into a compile-time error, but Walter (used to) wants it to compile. So at least I suggest your comment of Pull 375 to say this example is now a compile-time error. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5290Code like the following is working as designed, so if your patch refuses this code, then your patch is implementing an enhancement too (it means it's changing the D specs): int[3] arr = [1, 2]; void main() {}Note: For the situations where people want to specify less items than the arrays length I suggested an *explicit* syntax, like: int[3] arr = [1, 2, ...]; void main() {} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5290 See also: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=144210 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 09 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5290 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla digitalmars.com 12:57:27 PST ---The following invalid code is accepted: import std.stdio; void main() { real[2] foo = [1.0L]; writeln(foo); // [1, 0] }Running it gives: object.Exception src\rt\arraycat.d(31): lengths don't match for array copy -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 20 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5290D is statically typed, so it's better to refuse it at compile-time. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------The following invalid code is accepted: import std.stdio; void main() { real[2] foo = [1.0L]; writeln(foo); // [1, 0] }Running it gives: object.Exception src\rt\arraycat.d(31): lengths don't match for array copy
Jan 20 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5290 timon.gehr gmx.ch changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |timon.gehr gmx.ch Actually, it would be very cool if D would re-use the integer range trick here and catch all cases that can be proven not to work using it, such that the following code would error at compile time: ;) int x; readf("%d",&x); real[2] foo = x%100>50 ? [1.0L, 2.0L, 3.0L][0..2|x&1] : ([1.0L, 2.0L] ~ [3.0L, 4.0L] ~ 5.0L)[x&1..$-!(x&1)]; -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 20 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5290 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.auYes, but that's bug 2547. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------D is statically typed, so it's better to refuse it at compile-time.The following invalid code is accepted: import std.stdio; void main() { real[2] foo = [1.0L]; writeln(foo); // [1, 0] }Running it gives: object.Exception src\rt\arraycat.d(31): lengths don't match for array copy
Jan 24 2012