Skip to content

Commit

Permalink
Temporarily ignore "return" in non-method scope
Browse files Browse the repository at this point in the history
Currently TypeProf does not support `define_method`. A return statement
in `define_method` is considered as a non-method-scope return, which is
not well supported. This change temporarily ignores such a case.
  • Loading branch information
mame committed Aug 23, 2024
1 parent f18c568 commit aab5fac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/typeprof/core/ast/control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ def subnodes = { arg: }

def install0(genv)
@arg.install(genv)
e_ret = @lenv.get_var(:"*expected_method_ret")
@lenv.add_return_box(@changes.add_escape_box(genv, @arg.ret, e_ret))
e_ret = @lenv.locals[:"*expected_method_ret"]
@lenv.add_return_box(@changes.add_escape_box(genv, @arg.ret, e_ret)) if e_ret
Source.new(Type::Bot.new(genv))
end
end
Expand Down
8 changes: 8 additions & 0 deletions scenario/misc/define_method_return.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## update
class Foo
define_method(:foo) { return }
end

## assert
class Foo
end

0 comments on commit aab5fac

Please sign in to comment.