Ruby: reject ArrayElement[-n] instead of interpreting it as ArrayElement[?]

This commit is contained in:
Asger Feldthaus
2022-02-22 09:21:01 +01:00
parent a11c6f0f8e
commit bb9348d77f

View File

@@ -32,12 +32,18 @@ module SummaryComponent {
/** Gets a summary component that represents an element in an array at an unknown index. */
SummaryComponent arrayElementUnknown() { result = SC::content(TUnknownArrayElementContent()) }
/** Gets a summary component that represents an element in an array at a known index. */
/**
* Gets a summary component that represents an element in an array at a known index.
*
* Has no result for negative indices. Wrap-around interpretation of negative indices should be
* handled by the caller, if modeling a function that has such behavior.
*/
bindingset[i]
SummaryComponent arrayElementKnown(int i) {
result = SC::content(TKnownArrayElementContent(i))
or
// `i` may be out of range
i >= 0 and
not exists(TKnownArrayElementContent(i)) and
result = arrayElementUnknown()
}