Skip to content

feat: sanity checks for lookup vectors - #1037

Merged
DavePearce merged 1 commit into
mainfrom
972-feat-sanity-check-lookup-bitwidths
Jul 28, 2025
Merged

feat: sanity checks for lookup vectors#1037
DavePearce merged 1 commit into
mainfrom
972-feat-sanity-check-lookup-bitwidths

Conversation

@DavePearce

Copy link
Copy Markdown
Contributor

This puts in place some sanity checks for lookup vectors, such as looking for potentially negative coordinates.

This puts in place some sanity checks for lookup vectors, such as
looking for potentially negative coordinates.
@DavePearce DavePearce linked an issue Jul 28, 2025 that may be closed by this pull request
if vector.HasSelector() {
// Determine value range of ith term
valrange := vector.Selector.Unwrap().ValueRange(modmap)
// Determine bitwidth for that range

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Vector Lookup Bugs: Mismatched Lengths, Nil Terms

The checkLookupVector function contains two bugs:

  1. It can panic with an index out of bounds error when iterating vector.Terms and accessing terms[i], as the lengths of vector.Terms (translated mir.Terms) and terms (original ast.Exprs) are not guaranteed to match.
  2. It can panic with a null pointer dereference when calling ValueRange() on elements of vector.Terms or on vector.Selector.Unwrap(). This occurs if prior translation steps (translateUnitExpressions or translateExpression) resulted in nil mir.Terms being included in the vector.
Locations (1)

Fix in Cursor Fix in Web

@DavePearce
DavePearce merged commit c3ed6ca into main Jul 28, 2025
4 checks passed
@DavePearce
DavePearce deleted the 972-feat-sanity-check-lookup-bitwidths branch July 28, 2025 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: sanity check lookup bitwidths

1 participant