fix #21456: foreach over associative array allows incompatible types for key and value#21469
Conversation
…ypes for key and value fix the lambda parameter type to correspond to key or value
|
Thanks for your pull request, @rainers! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.
|
| Statement s = new ExpStatement(fs.loc, v); | ||
| fs._body = new CompoundStatement(fs.loc, s, fs._body); | ||
| if (taa) | ||
| p.type = i == 1 || fs.parameters.length == 1 ? taa.nextOf() : taa.index; |
There was a problem hiding this comment.
There's a similar case for autodecoding too:
void main() {
import core.stdc.stdio;
foreach (int i, dchar c; "abc")
printf("%d: %c\n", i, c);
}druntime's _aApplycd2() helper passes the pointers to (original size_t) index and value to the generated foreach-function. And that function then loads a 32-bit integer from the passed index pointer - so truncating to 32-bits on little-endian, but using the 32 upper bits for 64-bit big-endian targets. We have an LDC-specific fix for this (introduced in ldc-developers/ldc@bbdf473); we might be able to fuse these 2 fixes to a single one.
fix the lambda parameter type to correspond to key or value