Bug 12330 – array.reserve at compile time too

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-09T07:28:25Z
Last change time
2019-03-30T15:47:43Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-03-09T07:28:25Z
int[] foo() { int[] result; result.reserve = 5; return result; } enum r = foo(); void main() {} dmd 2.066alpha gives: ...\dmd2\src\druntime\import\object.di(550,31): Error: _d_arraysetcapacity cannot be interpreted at compile time, because it has no available source code test.d(3,11): called from here: reserve(result, 5u) test.d(6,13): called from here: foo() It could be useful for situations like Issue 12315
Comment #1 by dlang-bot — 2019-03-30T13:20:07Z
@Basile-z created dlang/druntime pull request #2532 "fix issue 12330 - array.reserve at compile time too" fixing this issue: - fix issue 12330 - array.reserve at compile time too makes reserve() a noop at compile-time allowing to CTFE https://github.com/dlang/druntime/pull/2532
Comment #2 by dlang-bot — 2019-03-30T15:47:43Z
dlang/druntime pull request #2532 "fix issue 12330 - array.reserve at compile time too" was merged into master: - e3c7e49653251661370a1ba21629b2d412874ab2 by Basile Burg: fix issue 12330 - array.reserve at compile time too makes reserve() a noop at compile-time allowing to CTFE https://github.com/dlang/druntime/pull/2532