diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-04-06 19:14:03 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-06 19:14:03 -0700 |
commit | 0b091fdac6ceb33b7379ceddc9a49a79d0e158b2 (patch) | |
tree | 3ec9799bb7c38ce87b24380f8008ed07467f48e5 /test/ruby/test_proc.rb | |
parent | bff12e1a9a726baef8d5d8876669a1506555ec09 (diff) |
Raise RuntimeError if Kernel#binding is called from a non-Ruby frame
Check whether the current or previous frame is a Ruby frame in
call_trace_func and rb_tracearg_binding before attempting to
create a binding for the frame.
Fixes [Bug #18487]
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5767
Merged-By: jeremyevans <code@jeremyevans.net>
Diffstat (limited to 'test/ruby/test_proc.rb')
-rw-r--r-- | test/ruby/test_proc.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 63c258744a..05c6e03aac 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -445,6 +445,11 @@ class TestProc < Test::Unit::TestCase assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427') end + def test_binding_error_unless_ruby_frame + define_singleton_method :binding_from_c!, method(:binding).to_proc >> ->(bndg) {bndg} + assert_raise(RuntimeError) { binding_from_c! } + end + def test_proc_lambda assert_raise(ArgumentError) { proc } assert_raise(ArgumentError) { assert_warn(/deprecated/) {lambda} } |