Bug 4140 – Error: non-constant expression "hello"[1u..__dollar]

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
Linux
Creation time
2010-05-01T15:24:00Z
Last change time
2014-02-15T02:20:37Z
Keywords
rejects-valid
Assigned to
nobody
Creator
nfxjfg

Comments

Comment #0 by nfxjfg — 2010-05-01T15:24:05Z
$ cat z.d const z = "hello"; const h = z[1..$]; $ dmd -c z.d z.d(2): Error: non-constant expression "hello"[1u..__dollar] Works with dmd2. Tested with dmd 1.59 beta (can only select up to 1.057 in bugzilla).
Comment #1 by strtr — 2010-07-21T23:13:35Z
Just found this one in D1.062 Windows. Workaround : use z.length iso $. const A = [1,2,3]; const B = A[1..A.length];
Comment #2 by bugzilla — 2011-04-08T09:59:09Z