Bug 7097 – opDollar doesn't work with slicing

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-12-11T09:24:00Z
Last change time
2012-10-28T22:24:41Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2011-12-11T09:24:42Z
struct S { @property size_t length() const { return 1; } S opSlice(size_t lower, size_t upper) { assert(0); } alias length opDollar; } void main() { S s; auto num = s[0..$]; } test9.d(13): Error: undefined identifier __dollar
Comment #1 by code — 2012-05-28T01:32:14Z
Comment #2 by github-bugzilla — 2012-10-28T18:15:14Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a88decb8a85efe2e9b59abb7e1fce752051dcdd6 Merge pull request #577 from dawgfoto/Bug7097 fix Issue 7097 - opDollar doesn't work with slicing
Comment #3 by bearophile_hugs — 2012-10-28T19:03:08Z
This is crashing dmd, do you want me to open a new bug report? static struct Foo { int[] opSlice(int a, int b) { return [a, b]; } int opDollar(int dim)() { return dim; } } void main() { Foo array; array[0 .. $]; } Assertion failure: 'd' on line 1401 in file 'dsymbol.c'
Comment #4 by code — 2012-10-28T20:54:11Z
Because we don't yet have multidimensional slices I forgot to test that combination. The fix is to by always use dim=0 for slices.
Comment #5 by code — 2012-10-28T21:15:47Z
Comment #6 by github-bugzilla — 2012-10-28T22:24:41Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2769221119945bff9afce0dd171b71d43b49427b Merge pull request #1233 from dawgfoto/fixupBug7097 fixup of pull #577