Skip to content

Read unsigned integer constants as unsigned - #277

Merged
coord-e merged 2 commits into
mainfrom
claude/uint-const-unsigned
Sep 24, 2026
Merged

coord-e merged 2 commits into
mainfrom
claude/uint-const-unsigned

Conversation

@coord-e

@coord-e coord-e commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

const_value_ty read Uint constants with ScalarInt::to_int, which sign-extends. So a constant with the high bit set, such as 255u8, became -1. As a result, let x: u8 = 255; assert!(x > 200); was reported as Unsat, and assert!(x < 200) verified.

This splits the arm so that Uint constants are read with to_uint.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WZXwt16ZiUmjT6hDYraDtb

const_value_ty read Uint constants with to_int, which sign-extends, so a
constant with the high bit set such as 255u8 became -1. Read them with
to_uint instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WZXwt16ZiUmjT6hDYraDtb
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-24T12:38:37.789341Z 0a5b097 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WZXwt16ZiUmjT6hDYraDtb

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The unsigned high-bit regression needs the required paired UI tests.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Corrects unsigned MIR constants so high-bit values are not sign-extended.

Changes:

  • Handles signed and unsigned constants separately.
  • Uses ScalarInt::to_uint for unsigned values.
File Description
src/​analyze/​basic_block.rs Corrects unsigned constant conversion.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/analyze/basic_block.rs
@coord-e
coord-e merged commit 262fba6 into main Sep 24, 2026
7 checks passed
@coord-e
coord-e deleted the claude/uint-const-unsigned branch September 24, 2026 12:37

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a5b0970c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

let val = val.to_uint(val.size());
PlaceType::with_ty_and_term(
rty::Type::int(),
chc::Term::int(val.try_into().unwrap()),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve unsigned constants wider than i64

For u64, usize on 64-bit targets, or u128 constants above i64::MAX, to_uint produces a u128 that this conversion cannot narrow to the i64 accepted by Term::int, so the unwrap() panics before verification. For example, analyzing let x: u64 = u64::MAX; assert!(x > 200); aborts here with TryFromIntError; represent the full unsigned value in the CHC term or report unsupported widths without panicking.

Useful? React with 👍 / 👎.

coeff-aij added a commit to coeff-aij/thrust that referenced this pull request Sep 24, 2026
…casts) into forall-sort

Brings in coord-e#114 (Rust expressions as thrust::predicate bodies,
instantiated per generic arguments), coord-e#275 (newer PCSat in CI), coord-e#276, coord-e#277
and coord-e#278 on top of forall-sort.

Resolution:
- A predicate call whose instance resolves goes through
  Analyzer::predicate_with_args, so a Rust-body predicate is defined once
  per instantiation and a raw SMT-LIB2 predicate keeps its single
  definition. A call that does not resolve (it still depends on the
  owner's type parameters) keeps the forall predicate.
- predicate_with_args takes the calling function as owner, since
  forall-sort translates type parameters relative to it; an instance
  whose arguments mention type parameters is keyed by that owner too.
- UserDefinedPredDef keeps both the new body enum and the ForallPred
  dependency set. A formula body contributes its ForallPred atoms
  directly and its calls to other user-defined predicates as edges of
  the dependency graph; a raw body is still scanned by name.
- The refinement clause builder records the value-variable origin only
  when the value term is a variable, as the singleton case substitutes
  a default term.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.

3 participants