Issue 7444 - Require [] for array copies too #702

Merged
merged 2 commits into from Mar 7, 2013

Conversation

Projects
None yet
4 participants
Member

9rnsr commented Feb 9, 2012

http://d.puremagic.com/issues/show_bug.cgi?id=7444

Deprecate ambiguity between slice assignment and element-wise one.
See test/runnable/assignable.d

Requires: D-Programming-Language/druntime#314 (merged)
Requires: D-Programming-Language/phobos#960

9rnsr closed this Feb 9, 2012

9rnsr reopened this Feb 10, 2012

Owner

andralex commented Sep 25, 2012

This looks good, and I like how you handled the covariance a lot. Kudos to @9rnsr! Now I know you'll hate this, but we can't pull this in without adequate documentation. Could you please find the time to write a draft?

Member

yebblies commented Oct 7, 2012

Fails to compile druntime

Member

9rnsr commented Oct 8, 2012

I've posted a pull request which fixes druntime code based on this enhancement.
See D-Programming-Language/druntime#314 .

Owner

WalterBright commented Nov 19, 2012

As I wrote on the bugzilla entry, I'm not sure this is worth code breakage.

Owner

WalterBright commented Nov 19, 2012

Maybe do it as a warning?

Member

9rnsr commented Nov 20, 2012

OK. I changed deprecation errors to warning.
And I posted an additional Phobos pull #960 (I've completely forgotten to post it).

9rnsr referenced this pull request in dlang/druntime Nov 22, 2012

Merged

Additional fix Issue 7444 in Posix platforms #352

Member

9rnsr commented Nov 22, 2012

Comemnt to re-run auto tester.

@WalterBright WalterBright added a commit that referenced this pull request Mar 7, 2013

@WalterBright WalterBright Merge pull request #702 from 9rnsr/fix7444
Issue 7444 - Require [] for array copies too
ba1009c

@WalterBright WalterBright merged commit ba1009c into dlang:master Mar 7, 2013

1 check was pending

default Pass: 9, Pending: 1
Details
@ghost

ghost commented Mar 10, 2013

Can we improve the error message here? Saying one syntax is better than the other without a reason in the error message has no meaning.

Also the message itself is unpleasant:

void main()
{
    int[] a;
    int[] b;
    a[] = b;
}
test.d(18): Warning: explicit element-wise assignment a[] = (b)[] is better than a[] = b

What's with the parenthesized b?

Another one:

void main()
{
    char[3] dst;
    char[3] src = [1, 2, 3];
    char* ptr = &dst[0];
    ptr[0 .. 3] = src;
}
Warning: explicit element-wise assignment ptr[cast(uint)0..cast(uint)3] = (src)[] is better than ptr[cast(uint)0..cast(uint)3] = src

This is an extremely ugly diagnostic, it needs to improve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment