Open
Conversation
c150bb9 to
9109e88
Compare
9109e88 to
e3c5863
Compare
vinistock
reviewed
Mar 29, 2023
lib/debug/thread_client.rb
Outdated
| M_RESPOND_TO_P = method(:respond_to?).unbind | ||
| M_METHOD = method(:method).unbind | ||
| M_OBJECT_ID = method(:object_id).unbind | ||
| M_NAME = Module.instance_method(:name) |
Member
There was a problem hiding this comment.
I think we can use the same pattern as above.
lib/debug/server_dap.rb
Outdated
| { name: name, | ||
| value: str, | ||
| type: type_name(obj), | ||
| type: type_name || type_name.to_s, |
Member
There was a problem hiding this comment.
Instead of using this or, can't we always invoke to_s?
cfd91dc to
bf582fd
Compare
st0012
reviewed
Mar 29, 2023
lib/debug/server_dap.rb
Outdated
| { name: name, | ||
| value: str, | ||
| type: type_name(obj), | ||
| type: type_name.to_s, |
Member
There was a problem hiding this comment.
type_name should already return a String so to_s may not be necessary?
Author
There was a problem hiding this comment.
Yeah, everything appears to be working fine when I use just type_name. Does that make the to_s test unnecessary?
bf582fd to
d7908fe
Compare
st0012
reviewed
Mar 29, 2023
test/protocol/variables_test.rb
Outdated
| end | ||
| end | ||
|
|
||
| class DAPOverwrittenToSMethod < ProtocolTestCase |
Member
There was a problem hiding this comment.
Now that we don't call to_s anymore, do we still need this test?
d7908fe to
670f96a
Compare
st0012
approved these changes
Mar 31, 2023
Member
st0012
left a comment
There was a problem hiding this comment.
Yeah I think it's good to open a PR upstream now. Just a reminder that the PR description should be concise but mention:
- What's the behavioural difference with examples (e.g. parts of the response content)
- Why it's better
vinistock
approved these changes
Mar 31, 2023
d59e3ca to
a136d09
Compare
a136d09 to
b83389a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
ruby#790 fixes this issue. In this issue, the debugger raises the error:
I took a look at the repository this error was occurring in to figure out what was causing it. Essentially, this
ArgumentErroris coming from theself.namefunction having the parametervaluewhich is not provided whenklass.nameis called here, causing an exception.In ruby#790, if there is an exception when trying to get the class name, the variable's
typeis set to"<Error: #{e.message} (#{e.backtrace.first}>".My first commit adds three tests that test this functionality:
namemethod. The type should be an error message that begins with<Error: wrong number of arguments (given 0, expected 1).to_smethod. The type should be the same error as 1.namemethod and returnnilbecause thetype_namemethod checksklass.namefirst and without overriding the method to returnnil, the test does not triggerklass.to_sclassmethod. This was added in becauseM_CLASS.bind_call(obj)is used rather thanobj.classso adding a test to ensure the class name is being set appropriately and not raising an error is useful.I noticed that rather than catching an exception and setting the type to an error message, it would be better to use
M_NAME.bind_call(klass)to get the type name as this does not callklass.nameso there would be no error. This is an approach that is used by Tapioca here.In my second commit, I implemented this approach. I updated the tests from my first commit to reflect the new changes including removing the
to_stest as this method is no longer being used. You can see thetypeis nowFooinstead of an error message. This is more correct.