-
Notifications
You must be signed in to change notification settings - Fork 217
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
Updated TracePoint #1943
Updated TracePoint #1943
Conversation
c2caf8c
to
c986477
Compare
@@ -257,7 +257,7 @@ class TracePoint < Object | |||
# C.foo | |||
# end | |||
# | |||
def defined_class: () -> Module | |||
def defined_class: () -> (Class | Module)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though Class | Module
is technically Module
, i think this is much clearer for the end-user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Give the type a try.
@@ -421,7 +421,7 @@ class TracePoint < Object | |||
# Value from exception raised on the `:raise` event, or rescued on the `:rescue` | |||
# event. | |||
# | |||
def raised_exception: () -> untyped | |||
def raised_exception: () -> Exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the case of other events than :raise
nor :rescue
?
def raised_exception: () -> Exception | |
def raised_exception: () -> Exception? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you call raised_exception
and there's no exception, it raises an error:
$ ruby -e 'TracePoint.trace(:line) { p _1.raised_exception }; p 1'
<internal:trace_point>:402:in `raised_exception': not supported by this event (RuntimeError)
from -e:1:in `block in <main>'
from -e:1:in `<main>'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💪
This PR updates
TracePoint
. There's a few idiosyncrasies (especially with some tests) that're discussed in the review comments