Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
November 10, 2010 [Issue 5199] New: null implicitly converts to any other type on array assignment | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5199 Summary: null implicitly converts to any other type on array assignment Product: D Version: D2 Platform: Other OS/Version: Windows Status: NEW Keywords: accepts-invalid, diagnostic Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: dsimcha@yahoo.com --- Comment #0 from David Simcha <dsimcha@yahoo.com> 2010-11-10 12:06:42 PST --- The following code compiles and shouldn't: struct Foo { double num; } void main() { Foo[] foo = new Foo[5]; foo[] = null; } It then fails at runtime with the following nonsensical error message: object.Exception: lengths don't match for array copy -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 10, 2010 [Issue 5199] null implicitly converts to any other type on array assignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5199 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #1 from bearophile_hugs@eml.cc 2010-11-10 12:15:53 PST --- It's an example of bug 3889 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 17, 2010 [Issue 5199] null implicitly converts to any other type on array assignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5199 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla@digitalmars.com Resolution| |INVALID --- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2010-11-16 20:13:51 PST --- null is a valid value for a slice, and the rvalue of the assignment is expected to be a slice. It's a slice with 0 length (which is still a valid slice), and for slice assignment to work the length of the lvalue must match the length of the rvalue. The message is correct - the lengths don't match. This is working as designed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 17, 2010 [Issue 5199] null implicitly converts to any other type on array assignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5199 --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2010-11-16 20:16:35 PST --- Bearophile is correct that this is a duplicate of bug 3889, which is an enhancement request. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 17, 2010 [Issue 5199] null implicitly converts to any other type on array assignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5199 --- Comment #4 from Sobirari Muhomori <dfj1esp02@sneakemail.com> 2010-11-16 21:34:06 PST --- I'd rather say it's a dup of bug 3395. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 17, 2010 [Issue 5199] null implicitly converts to any other type on array assignment | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Simcha | http://d.puremagic.com/issues/show_bug.cgi?id=5199 --- Comment #5 from Sobirari Muhomori <dfj1esp02@sneakemail.com> 2010-11-16 21:39:09 PST --- Disambiguation will make it hard to copy empty slices... well... such operation is not needed too much either. --- foo[]=(cast(Foo[])null)[]; //copy null slice foo[]=null; //should not typecheck, expected foo[]=Foo(...); --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation