[Issue 18268] Inconsistent decay of array types when passed to different callables
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 4 15:28:20 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=18268
Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |issues.dlang at jmdavisProg.co
| |m
--- Comment #1 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
When a template is implicitly instantiated with a dynamic array, the type of
the slice of that dynamic array is used (which is tail-const if the dynamic
array is const or tail-immutable if it's immutable). It does that so that you
don't have to explicitly slice dynamic arrays all over the place when using
templated code (though unfortunately, it does mean that dynamic arrays are
treated a bit special, since nothing like this happens with other types).
Explicitly instantiating a template with a dynamic array uses the exact type,
because you're providing the exact type rather than using type inference.
What I don't know is why lambda stuff ends up inferring the exact type of the
dynamic array in some cases and the type you get when slicing it in others.
--
More information about the Digitalmars-d-bugs
mailing list