3665 – Regression(1.051, 2.036) Assignment with array slicing does not work

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3665 - Regression(1.051, 2.036) Assignment with array slicing does not work
Summary: Regression(1.051, 2.036) Assignment with array slicing does not work
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 regression
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2010年01月02日 09:01 UTC by kai
Modified: 2014年04月18日 09:12 UTC (History)
3 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 kai 2010年01月02日 09:01:20 UTC
The following piece of code produces the error "Bug.d(13): Error: 'K[] = this.hash[]' is not of integral type, it is a ulong[]" with DMD 1.053 and DMD 1.054. It worked without problems in DMD 1.050.
final class Bug
{
	private ulong hash[8];
	protected void transform(ubyte[] input)
	{
		ulong K[8];
		ulong block[8];
		ulong state[8];
		block[] = cast(ulong[]) input;
		state[] = block[] ^ (K[] = hash[]);
	}
}
Comment 1 Don 2010年01月03日 11:44:14 UTC
Workaround is to add [], changing this:
state[] = block[] ^ (K[] = hash[]);
into
state[] = block[] ^ (K[] = hash[])[];
Comment 2 Don 2010年09月13日 01:00:54 UTC
This is very simple: in arrayop.c, the assignment operators have been left out of the lists of valid operations.
PATCH:
bool isArrayOpValid(Expression *e), line 54.
 case TOKand:
 case TOKor:
 case TOKpow:
 case TOKand:
 case TOKor:
 case TOKpow:
+ case TOKassign:
+ case TOKaddass:
+ case TOKminass:
+ case TOKmulass:
+ case TOKdivass:
+ case TOKmodass:
+ case TOKxorass:
+ case TOKandass:
+ case TOKorass:
+ case TOKpowass:
 return isArrayOpValid(((BinExp *)e)->e1) && isArrayOpValid(((BinExp *)e)->e2);
And again in isArrayOperand(), line 600
 case TOKand:
 case TOKor:
+ case TOKpow:
+ case TOKassign:
+ case TOKaddass:
+ case TOKminass:
+ case TOKmulass:
+ case TOKdivass:
+ case TOKmodass:
+ case TOKxorass:
+ case TOKandass:
+ case TOKorass:
+ case TOKpowass:
 case TOKneg:
 case TOKtilde:
 return 1;
Comment 3 Walter Bright 2010年09月21日 14:01:50 UTC
http://www.dsource.org/projects/dmd/changeset/681 


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