From 9c6714c17637fffa592e76e22a39fd4c90070dfc Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 17 Jun 2018 09:10:44 -0700 Subject: [PATCH 01/13] Remove unused imports --- hy/compiler.py | 4 +--- hy/importer.py | 2 +- hy/lex/parser.py | 4 ++-- tests/test_bin.py | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 04d195d..f72e19c 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -15,8 +15,7 @@ from hy.lex.parser import mangle, unmangle import hy.macros from hy._compat import ( - str_type, string_types, bytes_type, long_type, PY3, PY35, PY37, - raise_empty) + str_type, bytes_type, long_type, PY3, PY35, raise_empty) from hy.macros import require, macroexpand, tag_macroexpand import hy.importer @@ -27,7 +26,6 @@ import sys import copy from collections import defaultdict -from cmath import isnan if PY3: import builtins diff --git a/hy/importer.py b/hy/importer.py index 92c95b0..a93d1fd 100644 --- a/hy/importer.py +++ b/hy/importer.py @@ -5,7 +5,7 @@ from __future__ import absolute_import from hy.compiler import hy_compile, HyTypeError -from hy.models import HyObject, HyExpression, HySymbol +from hy.models import HyExpression, HySymbol from hy.lex import tokenize, LexException from hy.errors import HyIOError diff --git a/hy/lex/parser.py b/hy/lex/parser.py index fac2577..63ea277 100755 --- a/hy/lex/parser.py +++ b/hy/lex/parser.py @@ -6,11 +6,11 @@ from __future__ import unicode_literals from functools import wraps -import string, re, unicodedata +import re, unicodedata from rply import ParserGenerator -from hy._compat import PY3, str_type, isidentifier, UCS4 +from hy._compat import str_type, isidentifier, UCS4 from hy.models import (HyBytes, HyComplex, HyDict, HyExpression, HyFloat, HyInteger, HyKeyword, HyList, HySet, HyString, HySymbol) from .lexer import lexer diff --git a/tests/test_bin.py b/tests/test_bin.py index 7b34007..1a32e01 100644 --- a/tests/test_bin.py +++ b/tests/test_bin.py @@ -5,14 +5,13 @@ # license. See the LICENSE. import os -from pipes import quote import re import shlex import subprocess import pytest -from hy._compat import PY3, PY35, PY36, builtins +from hy._compat import builtins from hy.importer import get_bytecode_path From 3d3d1fe6ae5411e1bc39a84e20bde4726a2c22c7 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 17 Jun 2018 09:55:08 -0700 Subject: [PATCH 02/13] Remove unused compiler subroutines --- hy/compiler.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index f72e19c..c981f08 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -325,16 +325,6 @@ def _branch(results): return ret -def _raise_wrong_args_number(expression, error): - raise HyTypeError(expression, - error % (expression.pop(0), - len(expression))) - - -def _nargs(n): - return "%d argument%s" % (n, ("" if n == 1 else "s")) - - def is_unpack(kind, x): return (isinstance(x, HyExpression) and len(x) > 0 From d501b073d87817c548237ddb955e17d6991ed9de Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 17 Jun 2018 09:26:40 -0700 Subject: [PATCH 03/13] Fold compile_time_ns into the compiler --- hy/compiler.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index c981f08..61c9edb 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -34,17 +34,6 @@ else: Inf = float('inf') -_compile_time_ns = {} - - -def compile_time_ns(module_name): - ns = _compile_time_ns.get(module_name) - if ns is None: - ns = {'hy': hy, '__name__': module_name} - _compile_time_ns[module_name] = ns - return ns - - _stdlib = {} @@ -1596,11 +1585,17 @@ class HyASTCompiler(object): arg, self)) + _namespaces = {} + @special(["eval-and-compile", "eval-when-compile"], [many(FORM)]) def compile_eval_and_compile(self, expr, root, body): new_expr = HyExpression([HySymbol("do").replace(root)]).replace(expr) + if self.module_name not in self._namespaces: + # Initialize a compile-time namespace for this module. + self._namespaces[self.module_name] = { + 'hy': hy, '__name__': self.module_name} hy.importer.hy_eval(new_expr + body, - compile_time_ns(self.module_name), + self._namespaces[self.module_name], self.module_name) return (self._compile_branch(body) if ast_str(root) == "eval_and_compile" From 21f7ef0713ed7634399e97f7102278967cd42ef2 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 17 Jun 2018 09:37:14 -0700 Subject: [PATCH 04/13] Fold load_stdlib into the compiler --- hy/compiler.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 61c9edb..0099d8f 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -34,21 +34,6 @@ else: Inf = float('inf') -_stdlib = {} - - -def load_stdlib(): - import hy.core - if not _stdlib: - for module in hy.core.STDLIB: - mod = importlib.import_module(module) - for e in map(ast_str, mod.EXPORTS): - if getattr(mod, e) is not getattr(builtins, e, ''): - # Don't bother putting a name in _stdlib if it - # points to a builtin with the same name. This - # prevents pointless imports. - _stdlib[e] = module - def ast_str(x, piecewise=False): if piecewise: @@ -321,6 +306,9 @@ def is_unpack(kind, x): and x[0] == "unpack-" + kind) +_stdlib = {} + + class HyASTCompiler(object): def __init__(self, module_name): @@ -333,8 +321,17 @@ class HyASTCompiler(object): or module_name == "hy.core.macros") # Everything in core needs to be explicit (except for # the core macros, which are built with the core functions). - if self.can_use_stdlib: - load_stdlib() + if self.can_use_stdlib and not _stdlib: + # Populate _stdlib. + import hy.core + for module in hy.core.STDLIB: + mod = importlib.import_module(module) + for e in map(ast_str, mod.EXPORTS): + if getattr(mod, e) is not getattr(builtins, e, ''): + # Don't bother putting a name in _stdlib if it + # points to a builtin with the same name. This + # prevents pointless imports. + _stdlib[e] = module def get_anon_var(self): self.anon_var_count += 1 From 45ec57ab56365f285122bceacb0326982553a7f5 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 17 Jun 2018 09:54:59 -0700 Subject: [PATCH 05/13] 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 From 8a70d5c90fe248c1e303d94005ca5d8a3b8a579e Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 17 Jun 2018 10:10:53 -0700 Subject: [PATCH 06/13] Fold _branch into the compiler --- hy/compiler.py | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 7a67aa7..36d1c7e 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -272,26 +272,6 @@ class Result(object): ) -def _branch(results): - """Make a branch out of a list of Result objects - - This generates a Result from the given sequence of Results, forcing each - expression context as a statement before the next result is used. - - We keep the expression context of the last argument for the returned Result - """ - results = list(results) - ret = Result() - for result in results[:-1]: - ret += result - ret += result.expr_as_stmt() - - for result in results[-1:]: - ret += result - - return ret - - def is_unpack(kind, x): return (isinstance(x, HyExpression) and len(x) > 0 @@ -452,7 +432,20 @@ class HyASTCompiler(object): return compiled_exprs, ret, keywords def _compile_branch(self, exprs): - return _branch(self.compile(expr) for expr in exprs) + """Make a branch out of an iterable of Result objects + + This generates a Result from the given sequence of Results, forcing each + expression context as a statement before the next result is used. + + We keep the expression context of the last argument for the returned Result + """ + ret = Result() + for x in map(self.compile, exprs[:-1]): + ret += x + ret += x.expr_as_stmt() + if exprs: + ret += self.compile(exprs[-1]) + return ret def _storeize(self, expr, name, func=None): """Return a new `name` object with an ast.Store() context""" From 217fc2a487395853e53bae5fc0ba5ea2452c98aa Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Sun, 17 Jun 2018 16:09:47 -0700 Subject: [PATCH 07/13] Clean up _render_quoted_form --- hy/compiler.py | 78 ++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 43 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 36d1c7e..644ea5e 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -495,63 +495,55 @@ class HyASTCompiler(object): We need to distinguish them as want to concatenate them instead of just nesting them. """ - if level == 0: - if isinstance(form, HyExpression): - if form and form[0] in ("unquote", "unquote-splice"): - if len(form) != 2: - raise HyTypeError(form, - ("`%s' needs 1 argument, got %s" % - form[0], len(form) - 1)) - return set(), form[1], (form[0] == "unquote-splice") - if isinstance(form, HyExpression): - if form and form[0] == "quasiquote": - level += 1 - if form and form[0] in ("unquote", "unquote-splice"): - level -= 1 + op = None + if isinstance(form, HyExpression) and form and ( + isinstance(form[0], HySymbol)): + op = unmangle(ast_str(form[0])) + if level == 0 and op in ("unquote", "unquote-splice"): + if len(form) != 2: + raise HyTypeError(form, + ("`%s' needs 1 argument, got %s" % + op, len(form) - 1)) + return set(), form[1], op == "unquote-splice" + elif op == "quasiquote": + level += 1 + elif op in ("unquote", "unquote-splice"): + level -= 1 name = form.__class__.__name__ imports = set([name]) + body = [form] if isinstance(form, HySequence): - if not form: - contents = HyList() - else: + contents = [] + for x in form: + f_imps, f_contents, splice = self._render_quoted_form(x, level) + imports.update(f_imps) + if splice: + contents.append(HyExpression([ + HySymbol("list"), + HyExpression([HySymbol("or"), f_contents, HyList()])])) + else: + contents.append(HyList([f_contents])) + if form: # If there are arguments, they can be spliced # so we build a sum... - contents = HyExpression([HySymbol("+"), HyList()]) - - for x in form: - f_imports, f_contents, splice = self._render_quoted_form(x, - level) - imports.update(f_imports) - if splice: - to_add = HyExpression([ - HySymbol("list"), - HyExpression([HySymbol("or"), f_contents, HyList()])]) - else: - to_add = HyList([f_contents]) - - contents.append(to_add) - - return imports, HyExpression([HySymbol(name), - contents]).replace(form), False + body = [HyExpression([HySymbol("+"), HyList()] + contents)] + else: + body = [HyList()] elif isinstance(form, HySymbol): - return imports, HyExpression([HySymbol(name), - HyString(form)]).replace(form), False + body = [HyString(form)] elif isinstance(form, HyKeyword): - return imports, form, False + body = [HyString(form.name)] - elif isinstance(form, HyString): - x = [HySymbol(name), form] - if form.brackets is not None: - x.extend([HyKeyword("brackets"), form.brackets]) - return imports, HyExpression(x).replace(form), False + elif isinstance(form, HyString) and form.brackets is not None: + body.extend([HyKeyword("brackets"), form.brackets]) - return imports, HyExpression([HySymbol(name), - form]).replace(form), False + ret = HyExpression([HySymbol(name)] + body).replace(form) + return imports, ret, False @special(["quote", "quasiquote"], [FORM]) def compile_quote(self, expr, root, arg): From e2b98effda3921cd30f708ea15852051d52b1aa4 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Tue, 19 Jun 2018 16:23:49 -0700 Subject: [PATCH 08/13] Replace an unused variable with `_` --- hy/compiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hy/compiler.py b/hy/compiler.py index 644ea5e..2103928 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -548,7 +548,7 @@ class HyASTCompiler(object): @special(["quote", "quasiquote"], [FORM]) def compile_quote(self, expr, root, arg): level = Inf if root == "quote" else 0 # Only quasiquotes can unquote - imports, stmts, splice = self._render_quoted_form(arg, level) + imports, stmts, _ = self._render_quoted_form(arg, level) ret = self.compile(stmts) ret.add_imports("hy", imports) return ret From 00150c088c0ea6030c38dc0f04c29d2be97c3f9c Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Tue, 19 Jun 2018 16:24:02 -0700 Subject: [PATCH 09/13] Remove an unused helper method in the compiler --- hy/compiler.py | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 2103928..a3f2b5c 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -946,32 +946,6 @@ class HyASTCompiler(object): elts, ret, _ = self._compile_collect(args) return ret + asty.Tuple(expr, elts=elts, ctx=ast.Load()) - def _compile_generator_iterables(self, trailers): - """Helper to compile the "trailing" parts of comprehensions: - generators and conditions""" - - generators = trailers.pop(0) - - cond = self.compile(trailers.pop(0)) if trailers else Result() - - gen_it = iter(generators) - paired_gens = zip(gen_it, gen_it) - - gen_res = Result() - gen = [] - for target, iterable in paired_gens: - gen_res += self.compile(iterable) - gen.append(ast.comprehension( - target=self._storeize(target, self.compile(target)), - iter=gen_res.force_expr, - ifs=[], - is_async=False)) - - if cond.expr: - gen[-1].ifs.append(cond.expr) - - return gen_res + cond, gen - _loopers = many( tag('setv', sym(":setv") + FORM + FORM) | tag('if', sym(":if") + FORM) | From fca2eb93b02d227f476054da829e1e5ff0ebead0 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Tue, 19 Jun 2018 16:36:15 -0700 Subject: [PATCH 10/13] Remove dead code from HyASTCompiler.compile --- hy/compiler.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index a3f2b5c..8d7c81c 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -348,21 +348,18 @@ class HyASTCompiler(object): return Result() try: ret = self.compile_atom(tree) - if ret: - self.update_imports(ret) - return ret + self.update_imports(ret) + return ret except HyCompileError: # compile calls compile, so we're going to have multiple raise # nested; so let's re-raise this exception, let's not wrap it in # another HyCompileError! raise - except HyTypeError as e: + except HyTypeError: raise except Exception as e: raise_empty(HyCompileError, e, sys.exc_info()[2]) - raise HyCompileError(Exception("Unknown type: `%s'" % _type)) - def _compile_collect(self, exprs, with_kwargs=False, dict_display=False, oldpy_unpack=False): """Collect the expression contexts from a list of compiled expression. From bd675a5db67ed6b1bbb42da26c1f1b5149945d77 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Thu, 21 Jun 2018 10:56:19 -0700 Subject: [PATCH 11/13] Unmangle in compile_expression before build_method This ensures that e.g. the symbols "~" and "hyx_XtildeX" in the root position will both appear as "~" to the build method. --- hy/compiler.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 8d7c81c..d6752f2 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -954,7 +954,6 @@ class HyASTCompiler(object): @special(["lfor", "sfor", "gfor"], [_loopers, FORM]) @special(["dfor"], [_loopers, brackets(FORM, FORM)]) def compile_comprehension(self, expr, root, parts, final): - root = unmangle(ast_str(root)) node_class = { "for": asty.For, "lfor": asty.ListComp, @@ -1136,7 +1135,7 @@ class HyASTCompiler(object): else: assignments = [(k, v or k) for k, v in kids] - if root == HySymbol("import"): + if root == "import": ast_module = ast_str(module, piecewise=True) module = ast_module.lstrip(".") level = len(ast_module) - len(module) @@ -1158,7 +1157,7 @@ class HyASTCompiler(object): for k, v in assignments] ret += node( expr, module=module or None, names=names, level=level) - else: # root == HySymbol("require") + else: # root == "require" __import__(module) require(module, self.module_name, assignments=assignments, prefix=prefix) @@ -1170,8 +1169,9 @@ class HyASTCompiler(object): ops = {"and": (ast.And, "True"), "or": (ast.Or, "None")} opnode, default = ops[operator] + osym = expr[0] if len(args) == 0: - return asty.Name(operator, id=default, ctx=ast.Load()) + return asty.Name(osym, id=default, ctx=ast.Load()) elif len(args) == 1: return self.compile(args[0]) ret = Result() @@ -1179,16 +1179,16 @@ class HyASTCompiler(object): if any(value.stmts for value in values): # Compile it to an if...else sequence var = self.get_anon_var() - name = asty.Name(operator, id=var, ctx=ast.Store()) - expr_name = asty.Name(operator, id=var, ctx=ast.Load()) + name = asty.Name(osym, id=var, ctx=ast.Store()) + expr_name = asty.Name(osym, id=var, ctx=ast.Load()) temp_variables = [name, expr_name] def make_assign(value, node=None): positioned_name = asty.Name( - node or operator, id=var, ctx=ast.Store()) + node or osym, id=var, ctx=ast.Store()) temp_variables.append(positioned_name) return asty.Assign( - node or operator, targets=[positioned_name], value=value) + node or osym, targets=[positioned_name], value=value) current = root = [] for i, value in enumerate(values): @@ -1210,7 +1210,7 @@ class HyASTCompiler(object): ret = sum(root, ret) ret += Result(expr=expr_name, temp_variables=temp_variables) else: - ret += asty.BoolOp(operator, + ret += asty.BoolOp(osym, op=opnode(), values=[value.force_expr for value in values]) return ret @@ -1255,8 +1255,6 @@ class HyASTCompiler(object): @special(["**", "//", "<<", ">>"], [times(2, Inf, FORM)]) @special(["%", "^"], [times(2, 2, FORM)]) def compile_maths_expression(self, expr, root, args): - root = unmangle(ast_str(root)) - if len(args) == 0: # Return the identity element for this operator. return asty.Num(expr, n=long_type( @@ -1293,7 +1291,7 @@ class HyASTCompiler(object): @special(list(a_ops.keys()), [FORM, FORM]) def compile_augassign_expression(self, expr, root, target, value): - op = self.a_ops[unmangle(ast_str(root))] + op = self.a_ops[root] target = self._storeize(target, self.compile(target)) ret = self.compile(value) return ret + asty.AugAssign( @@ -1301,8 +1299,8 @@ class HyASTCompiler(object): @special("setv", [many(FORM + FORM)]) def compile_def_expression(self, expr, root, pairs): - if len(pairs) == 0: - return asty.Name(root, id='None', ctx=ast.Load()) + if not pairs: + return asty.Name(expr, id='None', ctx=ast.Load()) result = Result() for pair in pairs: result += self._compile_assign(*pair) @@ -1535,7 +1533,7 @@ class HyASTCompiler(object): @special(["eval-and-compile", "eval-when-compile"], [many(FORM)]) def compile_eval_and_compile(self, expr, root, body): - new_expr = HyExpression([HySymbol("do").replace(root)]).replace(expr) + new_expr = HyExpression([HySymbol("do").replace(expr[0])]).replace(expr) if self.module_name not in self._namespaces: # Initialize a compile-time namespace for this module. self._namespaces[self.module_name] = { @@ -1594,7 +1592,7 @@ class HyASTCompiler(object): expression[0], e.msg.replace("", "end of form"))) return Result() + build_method( - self, expression, expression[0], *parse_tree) + self, expression, unmangle(sfn), *parse_tree) if fn.startswith("."): # (.split "test test") -> "test test".split() From 88f33453dc9b6ca38a9e17924096512a5549efd0 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Thu, 21 Jun 2018 10:53:21 -0700 Subject: [PATCH 12/13] Minor cleanup for `raise` and `try` --- hy/compiler.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index d6752f2..5ece32f 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -575,6 +575,7 @@ class HyASTCompiler(object): @special("raise", [maybe(FORM), maybe(sym(":from") + FORM)]) def compile_raise_expression(self, expr, root, exc, cause): ret = Result() + if exc is not None: exc = self.compile(exc) ret += exc @@ -587,12 +588,10 @@ class HyASTCompiler(object): ret += cause cause = cause.force_expr - ret += asty.Raise( + return ret + asty.Raise( expr, type=ret.expr, exc=exc, inst=None, tback=None, cause=cause) - return ret - @special("try", [many(notpexpr("except", "else", "finally")), many(pexpr(sym("except"), @@ -685,8 +684,6 @@ class HyASTCompiler(object): # or # [] - # [variable [list of exceptions]] - # let's pop variable and use it as name name = None if len(exceptions) == 2: name = exceptions[0] @@ -697,21 +694,20 @@ class HyASTCompiler(object): if isinstance(exceptions_list, HyList): if len(exceptions_list): # [FooBar BarFoo] → catch Foobar and BarFoo exceptions - elts, _type, _ = self._compile_collect(exceptions_list) - _type += asty.Tuple(exceptions_list, elts=elts, ctx=ast.Load()) + elts, types, _ = self._compile_collect(exceptions_list) + types += asty.Tuple(exceptions_list, elts=elts, ctx=ast.Load()) else: # [] → all exceptions caught - _type = Result() + types = Result() else: - _type = self.compile(exceptions_list) + types = self.compile(exceptions_list) body = self._compile_branch(body) body += asty.Assign(expr, targets=[var], value=body.force_expr) body += body.expr_as_stmt() - # use _type.expr to get a literal `None` - return _type + asty.ExceptHandler( - expr, type=_type.expr, name=name, + return types + asty.ExceptHandler( + expr, type=types.expr, name=name, body=body.stmts or [asty.Pass(expr)]) @special("if*", [FORM, FORM, maybe(FORM)]) From af8907b151900f77ec3fa0cee8d90ae880b4fa32 Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Thu, 21 Jun 2018 11:38:03 -0700 Subject: [PATCH 13/13] Minor cleanup in compile_unary_operator --- hy/compiler.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 5ece32f..8fcb854 100755 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -1088,12 +1088,9 @@ class HyASTCompiler(object): ops = {"not": ast.Not, "~": ast.Invert} operand = self.compile(arg) - - operand += asty.UnaryOp( + return operand + asty.UnaryOp( expr, op=ops[root](), operand=operand.force_expr) - return operand - _symn = some(lambda x: isinstance(x, HySymbol) and "." not in x) @special(["import", "require"], [many(