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

[REG2.064] Issue 15778 - polysemous string type doesn't work in array operation #5511

Merged
merged 1 commit into from
Mar 10, 2016

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Mar 9, 2016

No description provided.

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
15778 [REG2.064] polysemous string type doesn't work in array operation

* to change code unit size for polysemous string literal.
*/
if (e2x.op == TOKstring)
e2x = e2x.implicitCastTo(sc, e1.type.constOf());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks weird to cast(const)"abc" the string literal when element-wise assignment of immutable to mutable scalar types should already work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For element-wise assignment, the each char elements in rhs needs to be converted to wchar, but the string literal typed immutable(char)[] is not implicitly convertible to wchar[] because implicitCastTo function cannot know that it can ignore the top-level conversion.

By the the target type change to e1.type.constOf() == const(wchar[]), the polysemous string literal will get a chance to modify its code unit size without immutability violation.

Other any D literals don't have immutable element type by default, so I think this is only for striing literals.

WalterBright added a commit that referenced this pull request Mar 10, 2016
[REG2.064] Issue 15778 - polysemous string type doesn't work in array operation
@WalterBright WalterBright merged commit f1ee0d0 into dlang:stable Mar 10, 2016
@9rnsr
Copy link
Contributor Author

9rnsr commented Mar 10, 2016

Thanks.

@9rnsr 9rnsr deleted the fix15778 branch March 10, 2016 12:30
tramker added a commit to tramker/dmd that referenced this pull request Mar 11, 2016
[REG2.064] Issue 15778 - polysemous string type doesn't work in array operation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants