This commit is contained in:
Ryan Gonzalez 2014-11-13 17:49:17 -06:00
parent a6d9a963b5
commit c9362d39c1

View File

@ -1268,7 +1268,8 @@ class HyASTCompiler(object):
def compile_decorate_expression(self, expr): def compile_decorate_expression(self, expr):
expr.pop(0) # with-decorator expr.pop(0) # with-decorator
fn = self.compile(expr.pop(-1)) fn = self.compile(expr.pop(-1))
if not fn.stmts or not isinstance(fn.stmts[-1], ast.FunctionDef): if not fn.stmts or not (isinstance(fn.stmts[-1], ast.FunctionDef) or
isinstance(fn.stmts[-1], ast.ClassDef)):
raise HyTypeError(expr, "Decorated a non-function") raise HyTypeError(expr, "Decorated a non-function")
decorators, ret = self._compile_collect(expr) decorators, ret = self._compile_collect(expr)
fn.stmts[-1].decorator_list = decorators fn.stmts[-1].decorator_list = decorators