Trying to setv a callable should raise a nice error
When trying to setv a callable, raise an error instead of showing the user an incredibly ugly backtrace. Closes #532. Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
This commit is contained in:
parent
2665b316cf
commit
d3520e5640
@ -2004,6 +2004,10 @@ class HyASTCompiler(object):
|
|||||||
result = self.compile(result)
|
result = self.compile(result)
|
||||||
ld_name = self.compile(name)
|
ld_name = self.compile(name)
|
||||||
|
|
||||||
|
if isinstance(ld_name.expr, ast.Call):
|
||||||
|
raise HyTypeError(name,
|
||||||
|
"Can't assign to a callable: `%s'" % str_name)
|
||||||
|
|
||||||
if result.temp_variables \
|
if result.temp_variables \
|
||||||
and isinstance(name, HyString) \
|
and isinstance(name, HyString) \
|
||||||
and '.' not in name:
|
and '.' not in name:
|
||||||
|
@ -519,3 +519,9 @@ def test_attribute_access():
|
|||||||
def test_cons_correct():
|
def test_cons_correct():
|
||||||
"""Ensure cons gets compiled correctly"""
|
"""Ensure cons gets compiled correctly"""
|
||||||
can_compile("(cons a b)")
|
can_compile("(cons a b)")
|
||||||
|
|
||||||
|
|
||||||
|
def test_bad_setv():
|
||||||
|
"""Ensure setv handles error cases"""
|
||||||
|
cant_compile("(setv if 1)")
|
||||||
|
cant_compile("(setv (a b) [1 2])")
|
||||||
|
Loading…
Reference in New Issue
Block a user