-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rosetta): variadic arguments may use kwargs syntax in Python (#1832)
When processing function calls, the signature of the function was not considered when it was available, and an object literal used as the final argument of a variadic call would be rendered as keyword arguments when this is actually not a correct way to render variadic values. This change attempts to read the resolved signature of the function beging called, in order to correctly render variadic values. Fixes #1821 --- By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license]. [Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
- Loading branch information
1 parent
3b1ba87
commit 079e147
Showing
6 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/jsii-rosetta/test/translations/statements/vararg_any_call.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
public void Test(Array _args) | ||
{ | ||
} | ||
|
||
Test(new Struct { Key = "Value", Also = 1337 }); | ||
|
||
Test(new Struct { Key = "Value" }, new Struct { Also = 1337 }); |
6 changes: 6 additions & 0 deletions
6
packages/jsii-rosetta/test/translations/statements/vararg_any_call.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
public void test(Array _args) { | ||
} | ||
|
||
test(Map.of("Key", "Value", "also", 1337)); | ||
|
||
test(Map.of("Key", "Value"), Map.of("also", 1337)); |
6 changes: 6 additions & 0 deletions
6
packages/jsii-rosetta/test/translations/statements/vararg_any_call.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def test(_args): | ||
pass | ||
|
||
test({"Key": "Value", "also": 1337}) | ||
|
||
test({"Key": "Value"}, {"also": 1337}) |
7 changes: 7 additions & 0 deletions
7
packages/jsii-rosetta/test/translations/statements/vararg_any_call.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function test(..._args: any[]): void { | ||
// ... | ||
} | ||
|
||
test({ Key: 'Value', also: 1337 }); | ||
|
||
test({ Key: 'Value' }, { also: 1337 }); |