4444 – Cannot index built-in array with expression tuple

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4444 - Cannot index built-in array with expression tuple
Summary: Cannot index built-in array with expression tuple
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, spec
Depends on:
Blocks:
Reported: 2010年07月10日 11:52 UTC by Shin Fujishiro
Modified: 2014年02月15日 02:44 UTC (History)
2 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 Shin Fujishiro 2010年07月10日 11:52:05 UTC
Expression tuples cannot be used for indexing built-in arrays:
--------------------
import std.typetuple;
void main()
{
 alias TypeTuple!(1) index;
 auto arr = new int[4];
 auto x = arr[index]; // error
}
--------------------
% dmd -o- -c test
test.d(6): Error: cannot implicitly convert expression (tuple(1)) of type (int) to uint
--------------------
While overloaded opIndex accepts expression tuple.
--------------------
import std.typetuple;
void main()
{
 alias TypeTuple!(1) index;
 S s;
 auto x = s[index]; // okay
}
struct S
{
 size_t opIndex(size_t i) { return i; }
}
--------------------
Comment 1 Kenji Hara 2011年07月14日 04:23:04 UTC
https://github.com/D-Programming-Language/dmd/pull/105 


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