dmd icon indicating copy to clipboard operation
dmd copied to clipboard

fix regression in #21773 failing to parse some array initializers with implicit constructor calls

Open rainers opened this issue 3 months ago • 2 comments

While trying test cases from bug reports regarding AA initialization, I noticed that #21773 caused the code in #20542 to no longer compile.

Better coercing array initializer types by forwarding element types to element initializers fixes that, but that causes issues in other tests, especially regarding static array initialization by supplying only a single element type. This is dealt with in ExpressionSemanticVisitor.visit(AssignExp) more consistently than in initializerToExpression(), but unfortuately the interpreter still relies on the latter (even though semantic analysis should have made it obsolete!?). So I moved that part to the interpreter.

I have also added the tests from #19209 and #18360, showing that even more initializers are possible when the type can be coerced from the declaration.

rainers avatar Sep 06 '25 10:09 rainers

Thanks for your pull request, @rainers!

Bugzilla references

Your 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 locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#21824"

dlang-bot avatar Sep 06 '25 10:09 dlang-bot

Not happy with how many changes were necessary after adding another test case, I restored the version from the original PR and leave the other case for another PR.

rainers avatar Sep 22 '25 05:09 rainers