-
Notifications
You must be signed in to change notification settings - Fork 154
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
Serialize length instead of end offset #873
Serialize length instead of end offset #873
Conversation
It'd be great if someone can investigate why start > end for that call node and fix it, I'm not familiar with that part of the code. |
@@ -113,7 +115,8 @@ public class Loader { | |||
int type = buffer.get() & 0xFF; | |||
int length = buffer.getInt(); | |||
int startOffset = buffer.getInt(); | |||
int endOffset = buffer.getInt(); | |||
int length = buffer.getInt(); | |||
int endOffset = startOffset + length; |
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.
We would most likely change Java nodes/tokens/locations to store length
instead of endOffset
, but first we need to fix that failing assert. Also doing so will temporarily break the Loader CI check of course.
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.
Let's do that separately in a later PR.
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.
Do you have an issue for this?
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.
Yes, #872 is about that
@eregon I think there is a bug in calculating the location of the call nodes. For this code: foo[bar, baz] = 1, 2, 3 we end up with
where it is obvious that the inner |
I hope the issue with the locations will be fixed at least for the array nodes due to #877 |
With #879 it goes further, thanks!
|
3f91023
to
efd78ef
Compare
TBH I am not sure what should the location of the call node be in this case: <<~EOF.chop
baz
EOF |
I would say it needs to cover at least I'm not against covering the entire heredoc (the whole code here) for the call node location, it just seems more complicated. |
If you are using this as a library to replace syntax then I think it needs to be union of receiver, method, args. I am not making up a compelling example but if you wanted to eliminate this call then how could you do it? If call was not the union of locations then you would have to process all calls by ignoring the calls offsets and calculate the unions of them by studying the parts. The other side of the same coin is what would you use the call offsets for when sometimes it does not capture the receiver offsets? |
I was wondering what the
So the location of the call node for the parser gem is Yeah, that's a good point, maybe it should indeed cover everything. |
efd78ef
to
37cc284
Compare
I'd like to measure the total serialized size for the top 100 gems, but that's blocked by one more case of start<end offset: #891 (comment) |
This is now ready to be merged. |
@@ -113,7 +115,8 @@ public class Loader { | |||
int type = buffer.get() & 0xFF; | |||
int length = buffer.getInt(); | |||
int startOffset = buffer.getInt(); | |||
int endOffset = buffer.getInt(); | |||
int length = buffer.getInt(); | |||
int endOffset = startOffset + length; |
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.
Do you have an issue for this?
This currently fails the added assert:
I found with
gdb --args ruby -Ilib -Itest $f test/parse_test.rb
:i.e. that call node has a start > end.