Merge pull request #753 from Tritlo/issue752
Added a fix for nested decorators. Fixes #752
This commit is contained in:
commit
7829b8752c
@ -1295,7 +1295,7 @@ class HyASTCompiler(object):
|
||||
isinstance(fn.stmts[-1], ast.ClassDef)):
|
||||
raise HyTypeError(expr, "Decorated a non-function")
|
||||
decorators, ret, _ = self._compile_collect(expr)
|
||||
fn.stmts[-1].decorator_list = decorators
|
||||
fn.stmts[-1].decorator_list = decorators + fn.stmts[-1].decorator_list
|
||||
return ret + fn
|
||||
|
||||
@builds("with*")
|
||||
|
@ -15,6 +15,15 @@
|
||||
(defclass cls []
|
||||
[[my_attr 456]]))
|
||||
|
||||
(defn test-decorator-clobbing []
|
||||
"NATIVE: Tests whether nested decorators work"
|
||||
(do
|
||||
(defn dec1 [f] (defn k [] (+ (f) 1)))
|
||||
(defn dec2 [f] (defn k [] (+ (f) 2)))
|
||||
(with-decorator dec1
|
||||
(with-decorator dec2
|
||||
(defn f [] 1)))
|
||||
(assert (= (f) 4))))
|
||||
|
||||
(defn test-decorators []
|
||||
"NATIVE: test decorators."
|
||||
|
Loading…
Reference in New Issue
Block a user