Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bandaid patch for Thread#raise #1668

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions core/thread.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -991,9 +991,8 @@ class Thread < Object
# from prog.rb:2:in `new'
# from prog.rb:2
#
def self?.raise: () -> bot
| (String message, ?cause: Exception?) -> bot
| (_Exception exception, ?untyped message, ?::Array[String] backtrace, ?cause: Exception?) -> bot
def raise: (?String message) -> nil
| (_Exception, ?_ToS message, ?Array[String] backtrace) -> nil

# <!--
# rdoc-file=thread.c
Expand Down
26 changes: 26 additions & 0 deletions test/stdlib/Thread_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,30 @@ def test_native_thread_id
Thread.current, :native_thread_id
)
end

def test_raise
t = Thread.new do
begin
sleep
rescue
retry
end
end
t.report_on_exception = false

assert_send_type "() -> nil",
t, :raise
assert_send_type "(String) -> nil",
t, :raise, "Error!"
assert_send_type "(singleton(StandardError)) -> nil",
t, :raise, StandardError
assert_send_type "(StandardError) -> nil",
t, :raise, StandardError.new('Error!')
assert_send_type "(singleton(StandardError), String) -> nil",
t, :raise, StandardError, 'Error!'
assert_send_type "(singleton(StandardError), String, Array[String]) -> nil",
t, :raise, StandardError, 'Error!', caller

t.kill
end
end