Bug 2416 – Slice of typedef'ed array should preserve the typedef'ed type
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-10-13T14:39:00Z
Last change time
2015-06-09T05:15:11Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
andrei
Comments
Comment #0 by andrei — 2008-10-13T14:39:49Z
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 by dfj1esp02 — 2008-10-14T03:34:48Z
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 by smjg — 2008-10-25T07:13:57Z
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;