fix regression for GDC: make return type of _d_assocarrayliteralTX consistent with V[K] in the AST#22612
fix regression for GDC: make return type of _d_assocarrayliteralTX consistent with V[K] in the AST#22612rainers wants to merge 1 commit intodlang:stablefrom
Conversation
…nsistent with V[K] in the AST
|
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. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "stable + dmd#22612" |
Hmm, I thought it was specified as a struct with a single pointer field in the language ABI spec, but apparently it's always been defined as:
The struct actually came from the old library implementation (all the way back from D1) and used as the parameter type all the hooks. The new implementation still inherits this though and the various reinterpret casts can be read as: auto toAA(struct PodAA aa)
{
return *(cast(struct AA!(K, V)*)&aa);
}As it's a bit late to change the ABI now. I'd probably err towards leaving GDC to return AssocArrayLiteralExp's as a constructor in the backend. Unless LDC interpreted the ABI of AAs as being a struct type too @kinke ? |
|
This PR adds a cast from |
|
I vaguely recall a former problem wrt. plain |
|
Looks suspiciously like So I think LDC is affected too? |
|
Ah, that's debuginfo only - okay there we represent it as struct. It's always been a |
|
@kinke ok. @rainers I get. Which is pendantically true. :-) I never actually noticed this behaviour before. int[int] toAA(void* ptr)
{
return cast(int[int])ptr;
}
int[int] toAA(short* ptr)
{
return cast(int[int])ptr;
}
int[int] toAA(float* ptr)
{
return cast(int[int])ptr;
}
struct S{}
int[int] toAA(S* ptr)
{
return cast(int[int])ptr;
}
class C{}
int[int] toAA(C ptr)
{
return cast(int[int])ptr;
}
int[int] toAA(void function() ptr)
{
return cast(int[int])ptr;
}DMD happily compiles all the above, how bizarre. Edit: And you can cast all the above back to an AA again, because why not? |
|
@ibuclaw good enough for #21066 (comment) ?