Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Mar 7, 2013

Conversation

9rnsr
Copy link
Contributor

@9rnsr 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: dlang/druntime#314 (merged)
Requires: dlang/phobos#960

@9rnsr 9rnsr closed this Feb 9, 2012
@9rnsr 9rnsr reopened this Feb 10, 2012
@andralex
Copy link
Member

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?

@yebblies
Copy link
Member

yebblies commented Oct 7, 2012

Fails to compile druntime

@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 8, 2012

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

braddr pushed a commit to braddr/dmd that referenced this pull request Oct 22, 2012
Minimal reverting of Issue 1824 - Object not const correct
@WalterBright
Copy link
Member

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

@WalterBright
Copy link
Member

Maybe do it as a warning?

@9rnsr
Copy link
Contributor Author

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
Copy link
Contributor Author

9rnsr commented Nov 22, 2012

Comemnt to re-run auto tester.

WalterBright added a commit that referenced this pull request Mar 7, 2013
Issue 7444 - Require [] for array copies too
@WalterBright WalterBright merged commit ba1009c into dlang:master Mar 7, 2013
@ghost
Copy link

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
Labels
None yet
Projects
None yet
4 participants