From 45ec57ab56365f285122bceacb0326982553a7f5 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 17 Jun 2018 09:54:59 -0700 Subject: [PATCH] Simplify Result.force_expr --- hy/compiler.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 0099d8f..7a67aa7 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -184,18 +184,11 @@ class Result(object): """ if self.expr: return self.expr - - # Spoof the position of the last statement for our generated None - lineno = 0 - col_offset = 0 - if self.stmts: - lineno = self.stmts[-1].lineno - col_offset = self.stmts[-1].col_offset - - return ast.Name(id=ast_str("None"), - ctx=ast.Load(), - lineno=lineno, - col_offset=col_offset) + return ast.Name( + id=ast_str("None"), + ctx=ast.Load(), + lineno=self.stmts[-1].lineno if self.stmts else 0, + col_offset=self.stmts[-1].col_offset if self.stmts else 0) def expr_as_stmt(self): """Convert the Result's expression context to a statement