Skip to content

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

Description

@mutahhir

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:

  let aSimpleThing = 
    aFunction();

Should be converted to the following in python:

    a_simple_thing = a_function()

Current Behavior

Current conversion is:

    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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions