diff --git a/transpile_python/service.go b/transpile_python/service.go index bab29fa..74e19ca 100644 --- a/transpile_python/service.go +++ b/transpile_python/service.go @@ -447,7 +447,18 @@ func handleSelectorExpr(expr ast.Expr) string { } func handleIndexExpr(expr *ast.IndexExpr) string { - code := expr.X.(*ast.Ident).String() + code := "" + + switch x := expr.X.(type) { + case *ast.Ident: + code += x.String() + // case *ast.CallExpr: + // code += x.... + default: + spew.Dump(x) + code += "unknown handleIndexExpr" + } + code += "[" code += expr.Index.(*ast.BasicLit).Value code += "]" diff --git a/transpile_python/service_test.go b/transpile_python/service_test.go index 8d49604..e75ede5 100644 --- a/transpile_python/service_test.go +++ b/transpile_python/service_test.go @@ -175,6 +175,20 @@ main() Compare(source, expected) }) + XIt("Assignments += by index of function call", func() { + source := `package test + func main() { + vkl_iface = vkl_iface_part(1)[0] + } + ` + expected := `from skidl import * +def main(): + vkl_iface = vkl_iface_part(1)[0] +main() +` + Compare(source, expected) + }) + It("Assignments &", func() { source := `package test func main() {