D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12091 - Possible inconsistency in array literals implicit cast
Summary: Possible inconsistency in array literals implicit cast
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2014-02-06 16:08 UTC by bearophile_hugs
Modified: 2024-12-13 18:16 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2014-02-06 16:08:47 UTC
I am not sure, but perhaps this shows an inconsistency worth fixing:


long[] foo() {
    return [1];         // OK
}
void main() {
    long[] a;
    auto b1 = a ~ 0;   // OK
    auto b2 = a ~ [0]; // Error
    auto c1 = 0 ~ a;   // OK
    auto c2 = [0] ~ a; // Error
}


dmd 2.065beta2 gives:

test.d(7): Error: incompatible types for ((a) ~ ([0])): 'long[]' and 'int[]'
test.d(9): Error: incompatible types for (([0]) ~ (a)): 'int[]' and 'long[]'
Comment 1 dlangBugzillaToGithub 2024-12-13 18:16:40 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17638

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB