digitalmars.D - Bug? opIn with associative array keyed on static arrays
- Peter Alexander (8/8) Jul 22 2018 void main() {
- ag0aep6g (17/24) Jul 22 2018 Definitely. Looks like `[2]` makes a dynamic array (length +
- Peter Alexander (2/10) Jul 23 2018 https://issues.dlang.org/show_bug.cgi?id=19112
void main() { int[int[1]] aa; aa[[2]] = 1; assert([2] in aa); } --- This assertion fails in 2081.1. Is this a bug? https://dpaste.dzfl.pl/d4c0d4607482
Jul 22 2018
On Sunday, 22 July 2018 at 19:42:45 UTC, Peter Alexander wrote:void main() { int[int[1]] aa; aa[[2]] = 1; assert([2] in aa); } --- This assertion fails in 2081.1. Is this a bug?Definitely. Looks like `[2]` makes a dynamic array (length + pointer) and `in` reinterprets it as an `int[1]`. More examples: ---- void main() { int[int[1]] aa = [[2]: 1]; assert([123, 456] in aa); /* Passes. Shouldn't even compile. */ size_t[] dynarr = [1, 2, 3]; string[size_t[2]] aa2 = [[3, cast(size_t) dynarr.ptr]: "Wat."]; assert(*(dynarr in aa2) == "Wat."); /* Passes. Shouldn't even compile. */ } ----
Jul 22 2018
On Sunday, 22 July 2018 at 19:42:45 UTC, Peter Alexander wrote:void main() { int[int[1]] aa; aa[[2]] = 1; assert([2] in aa); } --- This assertion fails in 2081.1. Is this a bug? https://dpaste.dzfl.pl/d4c0d4607482https://issues.dlang.org/show_bug.cgi?id=19112
Jul 23 2018