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

ag0aep6g anonymous at example.com
Thu Oct 5 05:49:16 UTC 2023


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 to have both `opApply` and 
> `empty`/`front`/`popFront` take precedence over this lowering, but I 
> have no idea how much existing code would be broken by such a change. At 
> the very least, though, this needs to be documented.
> 
> [1]: https://dlang.org/spec/statement.html#foreach-statement

For some further reading, there's an open issue about the unexpected 
slicing: https://issues.dlang.org/show_bug.cgi?id=14619


More information about the Digitalmars-d-learn mailing list