Add explicit cast in stc/core/stdcpp/array.d#2538
Conversation
|
Thanks for your pull request and interest in making D better, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + druntime#2538" |
| inout(T)* data() inout @safe { static if (N > 0) { return &_M_elems[0]; } else { return null; } } | ||
| /// | ||
| ref inout(T[N]) as_array() inout @trusted { return data()[0 .. N]; } | ||
| ref inout(T)[N] as_array() inout @trusted { return cast(inout(T)[N])data()[0 .. N]; } |
There was a problem hiding this comment.
I feel like that cast should never be necessary. Could you explain why it is ?
There was a problem hiding this comment.
inout(T[N]) cannot be converted to inout(T)[]. Note that the function was @trusted because the compiler inserted a cast implicitly.
There was a problem hiding this comment.
Why don't you access _M_elems directly, which already has the correct type?
There was a problem hiding this comment.
I wanted the change to be minimally invasive.
There was a problem hiding this comment.
I think it's better for it to be correct and avoiding casts.
Part 2 for [1] blockade.
[1] dlang/dmd#9505