Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Fable.Transforms/Python/Fable2Python.Transforms.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3216,7 +3216,14 @@ let declareEntryPoint (com: IPythonCompiler) (ctx: Context) (funcExpr: Expressio
[ Expression.stringConstant "__main__" ]
)

let main = Expression.call (funcExpr, [ args ]) |> Statement.expr |> List.singleton
let mainCall = Expression.call (funcExpr, [ args ])

// Propagate the entry point's return value as the process exit code.
// int(...) coercion is required because fable-library-python's Int32 is not an int subclass.
let main =
emitExpression None "sys.exit(int($0))" [ mainCall ]
|> Statement.expr
|> List.singleton

Statement.if' (test, main)

Expand Down
Loading