Skip to content

Commit cd441f7

Browse files
dkorpelthewilsonator
authored andcommitted
Fix #22902 - Named arguments not cleared after re-ordering
1 parent 6d6d83a commit cd441f7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

compiler/src/dmd/expressionsem.d

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6798,6 +6798,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
67986798
exp.arguments = new Expressions();
67996799
if (functionParameters(exp.loc, sc, tf, null, exp.type, exp.argumentList, f, exp.type, exp.argprefix))
68006800
return setError();
6801+
exp.names = null;
68016802

68026803
exp.member = f.isCtorDeclaration();
68036804
assert(exp.member);
@@ -6911,6 +6912,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
69116912
exp.arguments = new Expressions();
69126913
if (functionParameters(exp.loc, sc, tf, null, exp.type, exp.argumentList, f, exp.type, exp.argprefix))
69136914
return setError();
6915+
exp.names = null;
69146916

69156917
exp.member = f.isCtorDeclaration();
69166918
assert(exp.member);
@@ -8515,6 +8517,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
85158517
exp.arguments = new Expressions();
85168518
if (functionParameters(exp.loc, sc, cast(TypeFunction)t1, ethis, tthis, exp.argumentList, exp.f, exp.type, argprefix))
85178519
return setError();
8520+
exp.names = null;
85188521

85198522
if (!exp.type)
85208523
{

compiler/test/fail_compilation/named_arguments_error.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fail_compilation/named_arguments_error.d(42): missing argument for parame
1818
fail_compilation/named_arguments_error.d(34): `named_arguments_error.g(int x, int y, int z = 3)` declared here
1919
fail_compilation/named_arguments_error.d(44): Error: no named argument `element` allowed for array dimension
2020
fail_compilation/named_arguments_error.d(45): Error: no named argument `number` allowed for scalar
21-
fail_compilation/named_arguments_error.d(46): Error: cannot implicitly convert expression `g(x: 3, y: 4, z: 5)` of type `int` to `string`
21+
fail_compilation/named_arguments_error.d(46): Error: cannot implicitly convert expression `g(3, 4, 5)` of type `int` to `string`
2222
fail_compilation/named_arguments_error.d(47): Error: template `tempfun` is not callable using argument types `!()(int, int)`
2323
fail_compilation/named_arguments_error.d(47): argument `1` goes past end of parameter list
2424
fail_compilation/named_arguments_error.d(50): Candidate is: `tempfun(T, U)(T t, U u)`
@@ -43,7 +43,7 @@ void main()
4343

4444
auto g0 = new int[](element: 3);
4545
auto g1 = new int(number: 3);
46-
string s = g(x: 3, y: 4, z: 5);
46+
string s = g(z: 5, x: 3, y: 4);
4747
enum x = tempfun(u: 0, 1);
4848
}
4949

0 commit comments

Comments
 (0)