-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Can't read TreeNode.location from patch files #31579
Comments
Siggi has a workaround for this, so I'm removing the P1 status. We probably want to extend the kernel format later, so I've marked this "front-end-cleanup". |
We have a fileUri for fields and procedures and it was missing in constructors. This is needed to be able to correctly store the patch URI in patched constructors and to be able to workaround #31579. Change-Id: Ic80d3dc87450ada8b39b555e9b16e162d0e40b45 Reviewed-on: https://dart-review.googlesource.com/29003 Commit-Queue: Sigmund Cherem <sigmund@google.com> Reviewed-by: Jens Johansen <jensj@google.com> Reviewed-by: Kevin Millikin <kmillikin@google.com>
Temporarily use the patch URI for procedures and constructors and adjust file-offset on class metadata to workaround issue #31579. This change should be reverted when we have proper tracking of both origin and patch URIs for each patched element. Change-Id: I451a39b57cb121c2de3b1a324adc8cdbb5e8962c Reviewed-on: https://dart-review.googlesource.com/29004 Commit-Queue: Sigmund Cherem <sigmund@google.com> Reviewed-by: Peter von der Ahé <ahe@google.com>
TreeNode.location may return null "if the node is orphaned". This happens for instance in cases where nodes can't use a fileOffset due to patch files (see #31579). This will in turn obscure other errors as the error reporting code will crash trying to access members on null. TEST=existing. Bug: #31579 Change-Id: I85b720ecf2cb09e46cbd1296671be523567d5a83 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202920 Reviewed-by: Daco Harkes <dacoharkes@google.com> Commit-Queue: Clement Skau <cskau@google.com>
I'm repeatedly running into this issue (working with FfiNative, touching patch files) and the only workaround I have is to modify the transformations to remove the fileOffset from the affected nodes. Given this issue is nearing four years old it would be nice to see if we can put this on some kind of plan to fix. |
/cc @johnniwinther |
It is a known deficiency of the AST that it cannot hold file offsets for different files within the same member. The remedy is to set the file offsets to |
Do we by any chance have mechanisms for detecting when we're operating over the patch versions of a node in e.g. the transformations? (Something like |
We don't. |
For class members you could use |
With https://dart-review.googlesource.com/c/sdk/+/311660 |
Many nodes contain a fileoffset but no file uri. TreeNode.location searches up the tree to find the first node with a file uri (typically a member, class, or library). How does this work when using patch files?
It appears as if we use the tree node from the original library for these elements, and the body and annotations from the patch file are attached.
This is causing problems in the lookup of the location of these nodes. The offset corresponds to the patch file, but we try to look for it in the original library source instead. As a result we commonly hit "out-of-range" errors when calling TreeNode.location.
Here is a repro:
./tools/build.py -m release
sdk/bin/dart2js --use-kernel tests/language/aborting_switch_case_test.dart
You'll see this error:
The failure occurs when looking for the location of the
@patch
annotation inprintToConsole
.The text was updated successfully, but these errors were encountered: