Re: T[] opIndex() Error: .. signal 11

2023-10-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/5/23 1:49 AM, ag0aep6g wrote: For some further reading, there's an open issue about the unexpected slicing: https://issues.dlang.org/show_bug.cgi?id=14619 Thank you I had forgotten about that issue! -Steve

Re: T[] opIndex() Error: .. signal 11

2023-10-04 Thread ag0aep6g via Digitalmars-d-learn
On 03.10.23 20:26, Paul Backus wrote: Naturally, this lowering is completely absent from [the language spec's section on `foreach`.][1] According to the spec, the only ways to iterate over a `struct` type are `opApply` and the input range interface. I think it would probably be less confusing

Re: T[] opIndex() Error: .. signal 11

2023-10-03 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 3 October 2023 at 17:05:46 UTC, Steven Schveighoffer wrote: ```d void main() { S s = 0; { scope int[] __r3 = s.opIndex()[]; ulong __key4 = 0LU; for (; __key4 < __r3.length; __key4 += 1LU) {

Re: T[] opIndex() Error: .. signal 11

2023-10-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/3/23 11:12 AM, Joel wrote: The following program crashes, but doesn’t if I change (see title) T[] to auto. The program doesn’t even use that method/function. What’s the story? It's a stack overflow. when doing foreach on your type, the compiler *always* uses a slice first if it

Re: T[] opIndex() Error: .. signal 11

2023-10-03 Thread ryuukk_ via Digitalmars-d-learn
On Tuesday, 3 October 2023 at 15:12:34 UTC, Joel wrote: The following program crashes, but doesn’t if I change (see title) T[] to auto. The program doesn’t even use that method/function. What’s the story? ```d // Adding program - literal functions import std; struct List(T) { class Node

T[] opIndex() Error: .. signal 11

2023-10-03 Thread Joel via Digitalmars-d-learn
The following program crashes, but doesn’t if I change (see title) T[] to auto. The program doesn’t even use that method/function. What’s the story? ```d // Adding program - literal functions import std; struct List(T) { class Node { T data; Node next; this(T