diff --git a/transpile_python/service.go b/transpile_python/service.go index 8ea0ac8..6870ae7 100644 --- a/transpile_python/service.go +++ b/transpile_python/service.go @@ -136,6 +136,10 @@ func handleBasicLit(bl *ast.BasicLit) string { return bl.Value } +func handleCompositeLit(bl *ast.CompositeLit) string { + return "[]" +} + func handleUnaryExpr(expr *ast.UnaryExpr) string { code := expr.Op.String() code += handleExpr(expr.X) @@ -194,6 +198,8 @@ func handleExpr(expr ast.Expr) string { switch e := expr.(type) { case *ast.BasicLit: code += handleBasicLit(e) + case *ast.CompositeLit: + code += handleCompositeLit(e) case *ast.UnaryExpr: code += handleUnaryExpr(e) case *ast.BinaryExpr: diff --git a/transpile_python/service_test.go b/transpile_python/service_test.go index 3f32750..12c231d 100644 --- a/transpile_python/service_test.go +++ b/transpile_python/service_test.go @@ -98,6 +98,25 @@ main() Compare(source, expected) }) + It("Array assignment", func() { + source := `package test + import "skidl" + + func main() { + a := []any{} + a = []any{} + } + ` + expected := `from skidl import * + +def main(): + a = [] + a = [] +main() +` + Compare(source, expected) + }) + It("Function Declaration", func() { source := `package test import "skidl"