Improve checks inside defclass
We need to make sure we're looking at HyExpression when trying to determine if we're rewriting an __init__ expression. Fixes #1533
This commit is contained in:
parent
cf11e81c93
commit
84e1c65bcd
@ -2036,7 +2036,10 @@ class HyASTCompiler(object):
|
||||
def compile_class_expression(self, expressions):
|
||||
def rewire_init(expr):
|
||||
new_args = []
|
||||
if expr[0] == HySymbol("setv"):
|
||||
if (isinstance(expr, HyExpression)
|
||||
and len(expr) > 1
|
||||
and isinstance(expr[0], HySymbol)
|
||||
and expr[0] == HySymbol("setv")):
|
||||
pairs = expr[1:]
|
||||
while len(pairs) > 0:
|
||||
k, v = (pairs.pop(0), pairs.pop(0))
|
||||
|
@ -212,6 +212,9 @@ def test_ast_good_defclass():
|
||||
"Make sure AST can compile valid defclass"
|
||||
can_compile("(defclass a)")
|
||||
can_compile("(defclass a [])")
|
||||
can_compile("(defclass a [] None 42)")
|
||||
can_compile("(defclass a [] None \"test\")")
|
||||
can_compile("(defclass a [] None (print \"foo\"))")
|
||||
|
||||
|
||||
@pytest.mark.skipif(not PY3, reason="Python 3 supports class keywords")
|
||||
|
Loading…
Reference in New Issue
Block a user