Skip to content

Commit

Permalink
Merge pull request #45 from quarantin/master
Browse files Browse the repository at this point in the history
Fix two issues with ast.to_lua_source()
  • Loading branch information
boolangery authored Sep 11, 2023
2 parents 7845d30 + b86cb25 commit 4a93322
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions luaparser/printers.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,10 @@ def visit(self, node: Assign) -> str:

@visit.register
def visit(self, node: LocalAssign) -> str:
return "local " + self.do_visit(node.targets) + " = " + self.do_visit(node.values)
res = self.do_visit(node.values)
if res == '':
return "local " + self.do_visit(node.targets)
return "local " + self.do_visit(node.targets) + " = " + res

@visit.register
def visit(self, node: While) -> str:
Expand Down Expand Up @@ -314,7 +317,10 @@ def visit(self, node: Break) -> str:

@visit.register
def visit(self, node: Return) -> str:
return "return " + self.do_visit(node.values)
res = self.do_visit(node.values)
if res == "False":
return "return"
return "return " + res

@visit.register
def visit(self, node: Fornum) -> str:
Expand Down

0 comments on commit 4a93322

Please sign in to comment.