2416 – Slice of typedef'ed array should preserve the typedef'ed type

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2416 - Slice of typedef'ed array should preserve the typedef'ed type
Summary: Slice of typedef'ed array should preserve the typedef'ed type
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Linux
: P2 normal
Assignee: Walter Bright
URL:
Keywords: rejects-valid
Depends on:
Blocks:
Reported: 2008年10月13日 14:39 UTC by Andrei Alexandrescu
Modified: 2015年06月09日 05:15 UTC (History)
1 user (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 Andrei Alexandrescu 2008年10月13日 14:39:49 UTC
typedef const(char)[] A;
A stripl(A s)
{
 uint i;
 return s[i .. $];
}
This should work. A slice of a typedef'ed array should not spoil the typedef.
Comment 1 anonymous4 2008年10月14日 03:34:48 UTC
typedef as subtype of const(char)[] just "inherits" methods of its supertype including opSlice :)
which is defined as
const(char)[] opSlice(size_t, size_t)
Comment 2 Stewart Gordon 2008年10月25日 07:13:57 UTC
That's true of operator overloads defined by the programmer. This, OTOH, is a built-in operation on a built-in type form. Therefore the code is valid, just like
typedef int Value;
Value a, b, c;
...
a = b + c;
Comment 3 Walter Bright 2009年03月11日 14:52:46 UTC
Fixed dmd 1.041 and 2.026


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