Skip to content
Permalink
Browse files

Merge pull request #854 from kachick/fix-some-defined

Guard `defined?` from segfault with default value
  • Loading branch information
alex committed Oct 22, 2015
2 parents 6937882 + 754f131 commit c9ad0aa18b78129c5d5704534bc57cda461fcd15
Showing with 7 additions and 0 deletions.
  1. +4 −0 tests/test_interpreter.py
  2. +3 −0 topaz/ast.py
@@ -1105,6 +1105,10 @@ def test_defined(self, space):
""")
assert space.str_w(w_res) == "expression"
w_res = space.execute("""
return [defined?(while x do y end), defined?(return), defined?(__FILE__)]
""")
assert self.unwrap(space, w_res) == ["expression", "expression", "expression"]
w_res = space.execute("""
$abc = 3
return [defined?($abc), defined?($abd)]
""")
@@ -21,6 +21,9 @@ def compile(self, ctx):
else:
raise NotImplementedError(type(self).__name__)

def compile_defined(self, ctx):
ConstantString("expression").compile(ctx)


class Node(BaseNode):
_attrs_ = ["lineno"]

0 comments on commit c9ad0aa

Please sign in to comment.
You can’t perform that action at this time.