2546 – Array Ops silently fail when no slice symbol is used.

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2546 - Array Ops silently fail when no slice symbol is used.
Summary: Array Ops silently fail when no slice symbol is used.
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: accepts-invalid, wrong-code
Depends on:
Blocks:
Reported: 2008年12月30日 16:22 UTC by David Simcha
Modified: 2015年06月09日 01:20 UTC (History)
2 users (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 David Simcha 2008年12月30日 16:22:45 UTC
import std.stdio;
void main() {
 double[] foo = [1.0,2,3,4,5].dup;
 double[] bar = [6.0,7,8,9,10].dup;
 foo[] += bar; // foo now still == [1.0, 2.0, 3.0, 4.0, 5.0].
 writeln(foo);
 foo[] += bar[]; // Works.
 writeln(foo);
 uint[] intFoo = [1u,2,3,4,5].dup;
 uint[] intBar = [6u,7,8,9,10].dup;
 intFoo[] += intBar; // intFoo is now [6,7,8,9,10].
 writeln(intFoo);
 intFoo[] += intBar[];
 writeln(intFoo); // Works.
}
The compiler should either reject array ops in the form of foo[] += bar, or it should work. Either way, it should not fail silently with results that are arbitrary and inconsistent among types.
Comment 1 Walter Bright 2010年05月31日 19:02:59 UTC
http://www.dsource.org/projects/dmd/changeset/509 


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