-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Incorrect file/line blamed for errors caused by new SomeClass
#7771
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
Comments
Reporting the line of the AST evaluation would indeed be preferable, and I believe the necessary information is already present, but not used. |
Note that this is not a fatal error and thus can be caught. https://3v4l.org/ghG5d#v8.1.0 Not sure what the full stack trace should be if this were to be changed to the position of the constant itself. Just one more frame with the constant AST itself? |
I created a small POC here. https://github.com/php/php-src/compare/master...iluuu1994:gh-7771?expand=1 The approach in the PR is to simply replace filename/lineno in the exception, similar to Unfortunately the lineno in the AST somewhere. I'm still trying to figure out why. Let me know if this approach is ok before I spend too much time on this. |
Description
https://3v4l.org/UtjRl
This code should blame line 4, not line 7, since that's where the bogus constant is actually declared.
An example of where this is more problematic:
SomeClass.php
test.php
Resulted in this output:
But I expected this output instead:
This frequently causes issues with my telemetry because incorrect subsystems are getting blamed for errors when third-party plugin code comes into play.
PHP Version
8.0.13
Operating System
Windows (doubtful if relevant)
The text was updated successfully, but these errors were encountered: