Bug 14757 – Wrong error message: Error: multi-dimensional slicing requires template opSlice

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-07-01T18:32:01Z
Last change time
2024-12-13T18:43:38Z
Keywords
bootcamp, diagnostic
Assigned to
No Owner
Creator
Timothee Cour
Moved to GitHub: dmd#17715 →

Comments

Comment #0 by timothee.cour2 — 2015-07-01T18:32:01Z
---- struct A{ auto opSlice(uint dim)(int a, int b){ foobar(); return 0; } auto opIndex(T...)(T args){ return 2; } } void main(){ A a; a[0..1, 0];//Error: multi-dimensional slicing requires template opSlice //a[0..1];//slightly less cryptic error message for this } ----
Comment #1 by timothee.cour2 — 2015-07-01T18:34:55Z
forgot to add: of course the error is that 'foobar()' doesn't compile, but the error message provided completely hides that, and is confusing, since user did define opSlice. I'm guessing implementation uses something such as __traits(compiles, expr) to check whether user defined the template and error gagging prevents showing it. Either way, as it is, in larger programs, it can be very hard to figure out the reason of the bug given poor compiler msg
Comment #2 by robert.schadek — 2024-12-13T18:43:38Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17715 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB