diff --git a/hy/compiler.py b/hy/compiler.py index 2143fd4..8b3e1c2 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -1452,25 +1452,22 @@ class HyASTCompiler(object): raise HyTypeError(expr, "with expects a list, received `{0}'".format( type(args).__name__)) - if len(args) < 1: - raise HyTypeError(expr, "with needs [[arg (expr)]] or [[(expr)]]]") - - args.reverse() - ctx = self.compile(args.pop(0)) + if len(args) not in (1, 2): + raise HyTypeError(expr, "with needs [arg (expr)] or [(expr)]") thing = None - if args != []: + if len(args) == 2: thing = self._storeize(args[0], self.compile(args.pop(0))) + ctx = self.compile(args.pop(0)) body = self._compile_branch(expr) + # Store the result of the body in a tempvar var = self.get_anon_var() name = ast.Name(id=ast_str(var), arg=ast_str(var), ctx=ast.Store(), lineno=expr.start_line, col_offset=expr.start_column) - - # Store the result of the body in a tempvar body += ast.Assign(targets=[name], value=body.force_expr, lineno=expr.start_line,