analyzer: FieldError & BoundsError analysis#404
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #404 +/- ##
==========================================
- Coverage 64.68% 64.65% -0.03%
==========================================
Files 44 44
Lines 5111 5212 +101
==========================================
+ Hits 3306 3370 +64
- Misses 1805 1842 +37
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4777a56 to
f42ab2e
Compare
f42ab2e to
458e23c
Compare
Add static analysis for field access errors by hooking into `CC.builtin_tfunction` to intercept `getfield`, `setfield!`, `fieldtype`, and `getglobal` calls. Two new report types are introduced: - `FieldErrorReport` (`inference/field-error`): reported when accessing a non-existent field by name - `BoundsErrorReport` (`inference/bounds-error`): reported when accessing a field by an out-of-bounds integer index Note that the `inference/bounds-error` diagnostic is reported when code attempts to access a struct field using an integer index that is out of bounds, such as `getfield(x, i)` or tuple indexing `tpl[i]`, and not reported for arrays, since the compiler doesn't track array shape information. Reports from invalid `setfield!` and `fieldtype`, and general invalid argument types are left as future TODO. Also adjusts concrete evaluation logic to enable ad-hoc constant propagation after failed concrete evaluation for better accuracy.
458e23c to
8d048b6
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.
Analyzer: FieldError & BoundsError analysis
Add static analysis for field access errors by hooking into
CC.builtin_tfunctionto interceptgetfield,setfield!,fieldtype, andgetglobalcalls.Two new report types are introduced:
FieldErrorReport(inference/field-error): reported when accessinga non-existent field by name
BoundsErrorReport(inference/bounds-error): reported whenaccessing a field by an out-of-bounds integer index
Note that the
inference/bounds-errordiagnostic is reported when codeattempts to access a struct field using an integer index that is out of
bounds, such as
getfield(x, i)or tuple indexingtpl[i], and notreported for arrays, since the compiler doesn't track array shape
information.
Reports from invalid
setfield!andfieldtype, and general invalidargument types are left as future TODO.
Also adjusts concrete evaluation logic to enable ad-hoc constant
propagation after failed concrete evaluation for better accuracy.
Closes #392
Also fixes #327