Add macro expansion in defclass
This commit is contained in:
parent
c5e2fd955f
commit
41806895b2
1
AUTHORS
1
AUTHORS
@ -54,3 +54,4 @@
|
||||
* Ed Singleton <singletoned@gmail.com>
|
||||
* Kevin Yap <me@kevinyap.ca>
|
||||
* Matthías Páll Gissurarson <mpg@mpg.is>
|
||||
* Nathan Woodrow <woodrow.nathan@gmail.com>
|
||||
|
@ -2006,6 +2006,8 @@ class HyASTCompiler(object):
|
||||
expression,
|
||||
"Wrong argument type for defclass attributes definition.")
|
||||
for b in body_expression:
|
||||
if isinstance(b, HyExpression):
|
||||
b = macroexpand(b, self.module_name)
|
||||
if len(b) != 2:
|
||||
raise HyTypeError(
|
||||
expression,
|
||||
|
@ -83,3 +83,11 @@
|
||||
(assert (= mL.x 1))
|
||||
(assert (in "begin" mL.__doc__))
|
||||
(assert (in "end" mL.__doc__)))
|
||||
|
||||
(defn test-defclass-macroexpand []
|
||||
"NATIVE: test defclass with macro expand"
|
||||
(defmacro M [] `[x (fn [self x] (setv self._x x))])
|
||||
(defclass A [] [(M)])
|
||||
(setv a (A))
|
||||
(a.x 1)
|
||||
(assert (= a._x 1)))
|
||||
|
Loading…
Reference in New Issue
Block a user