-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rosetta): incorrect transliteration of map keys in python (#3449)
The Python transliterator failed to properly account for maps when transliterating keys, resulting in name-mangling being applied on these when it should not have been. This PR adds a new `inMap` context entry to track whether a property assignment must be interpreted as a map key-value entry, or an actual keyword/value mapping; and in that case circumvents the mangling. Added a new test to verify that such map literals render appropriately using a key similar to that which caused #3448. Fixes #3448 --- 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
5b4b852
commit 54cebaa
Showing
9 changed files
with
50 additions
and
14 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
3 changes: 1 addition & 2 deletions
3
packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
3 changes: 3 additions & 0 deletions
3
packages/jsii-rosetta/test/translations/expressions/map-literal.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,3 @@ | ||
IDictionary<string, object> map = new Dictionary<string, object> { | ||
{ "Access-Control-Allow-Origin", "\"*\"" } | ||
}; |
3 changes: 3 additions & 0 deletions
3
packages/jsii-rosetta/test/translations/expressions/map-literal.go
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,3 @@ | ||
map := map[string]interface{}{ | ||
"Access-Control-Allow-Origin": jsii.String("\"*\""), | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/jsii-rosetta/test/translations/expressions/map-literal.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,2 @@ | ||
Map<String, Object> map = Map.of( | ||
"Access-Control-Allow-Origin", "\"*\""); |
3 changes: 3 additions & 0 deletions
3
packages/jsii-rosetta/test/translations/expressions/map-literal.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,3 @@ | ||
map = { | ||
"Access-Control-Allow-Origin": "\"*\"" | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/jsii-rosetta/test/translations/expressions/map-literal.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,3 @@ | ||
const map: { [key: string]: unknown; } = { | ||
'Access-Control-Allow-Origin': '"*"', | ||
}; |