aws / aws/jsii-rosetta

`jsii-rosetta`: Multi-line assignment statement where function is on the right hand side breaks in Python

Open
#3,655 1 comment 0 reactions 0 assignees View on GitHub
bug p2
Dominant language
TypeScript
Stars
30
Forks
22
Avg merge
1h 28m
Merged PRs (30d)
44

Description

### Describe the bug

Rosetta respects a multi-line assignment when the right hand side expression is a function, which is not allowed in Python.

It's interesting to note that the same doesn't happen with other types that I've tested, so primitives, arrays, maps etc. are not a problem because rosetta forces them on the same line even when it's a multi-line assignment in Typescript.

### Expected Behavior

The following code in Typescript:

```ts
let aSimpleThing =
aFunction();
```

Should be converted to the following in python:

```py
a_simple_thing = a_function()
```

### Current Behavior

Current conversion is:

```py
a_simple_thing =
a_function()
```

which is a syntax error in Python

### Reproduction Steps

The following Typescript code should be enough to reproduce the error when converted with rosetta to Python:

```ts
function aFunction() {
return "hello";
}

export function main() {
let aSimpleThing =
aFunction();

return aSimpleThing;
}
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### SDK version used

1.75.0

### Environment details (OS name and version, etc.)

Mac OS 13.2 Arm64

Contributor guide

Open the contributing guide

Research direction

Start with the TypeScript reproduction in the issue and run it through jsii-rosetta targeting Python. Trace how multi-line assignments with function calls on the right-hand side are emitted, then add coverage for this case. Done means the generated assignment keeps the function call on the same valid Python statement and the conversion test passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.