Did the implicit conversion from special slice expression to static array ever work?
Nick Treleaven
nick at geany.org
Thu Sep 22 15:19:24 UTC 2022
On Thursday, 22 September 2022 at 14:31:46 UTC, Quirin Schroll
wrote:
> On Thursday, 22 September 2022 at 12:48:18 UTC, Nick Treleaven
> wrote:
>> If you make `i` const, it does work, but it has to be
>> initialized from a compile-time expression too. It should work
>> with a runtime initializer so long as `i` is const.
>
> This misses the point entirely. The spec is about run-time
> expressions. It is very clear about that implicitly using the
> phrase “no side effects”. Reading a compile-time constant is a
> very special case of no side effects.
Well I said a const runtime value should work (not just a
compile-time constant as works now). const there would make it
easy for the compiler to tell there are no side effects. I think
you are right that a mutable variable simple lvalue should work
as well. Some expressions do have side effects and to ensure
every kind of non-side effect expression might require an
optimization pass.
I found this is in bugzilla where `m_data[offset .. offset +
14];` is not recognised:
https://issues.dlang.org/show_bug.cgi?id=9165#c1
More information about the Digitalmars-d
mailing list