Permalink
Browse files

raise an inference error when method has same name as macro. fixes #123

  • Loading branch information...
baroquebobcat committed Oct 16, 2011
1 parent 6517a90 commit 7a933f353fa4cd11f3a813ce67a02aa68787b31b
Showing with 21 additions and 3 deletions.
  1. +8 −3 lib/mirah/ast/method.rb
  2. +13 −0 test/jvm/test_macros.rb
View
@@ -264,11 +264,16 @@ def infer(typer, expression)
inferred_type = body ? typer.infer(body, body_is_expression) : typer.no_type
if inferred_type && arguments.inferred_type.all?
actual_type = if forced_type.nil?
inferred_type
else
actual_type = if forced_type
forced_type
else
inferred_type
end
if actual_type.kind_of? Mirah::AST::InlineCode
raise Mirah::Typer::InferenceError.new("Method %s has the same signature as macro of the same name." % name,self)
end
if actual_type.unreachable?
actual_type = typer.no_type
end
View
@@ -144,4 +144,17 @@ def test_block_parameter_uses_outer_scope
end
end
def test_method_def_after_macro_def_with_same_name_raises_error
assert_raises Mirah::InferenceError do
compile(<<-EOF)
macro def foo
quote { puts :z }
end
def foo
:bar
end
EOF
end
end
end

0 comments on commit 7a933f3

Please sign in to comment.