Repository navigation
Fix CTFE evaluation of symbolic array repeats - #1556
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ab67f04 to
6406c60
Compare
6406c60 to
f419954
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f41995483d
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2267c7ded
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 170d6d2a8a
ℹ️ 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".
a6ee335 to
338e194
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 338e194151
ℹ️ 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".
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e1c02fed82
ℹ️ 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".
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Preserve repeat elements and extents in abstract constants until specialization. Retain deferred bounds checks and evaluate repeat operands before materializing arrays, including zero-length arrays with deferred element failures. Cover nested and record constants, associated lengths, substitution, runtime reification, invalid elements, and independent mutation of repeated arrays. Validation: nightly workspace formatting; strict all-target/all-feature workspace Clippy with warnings denied; full all-feature release nextest suite (3,357 passed, one existing ignored test).
Separate dependent descriptions, verified values, and formal runtime evidence. Replay blocked computations from immutable requests, preserve generic ownership and source diagnostics, and share primitive semantics and resource accounting. Consolidate retained-term forcing and immutable payloads, remove independent runtime evaluation and fallback success, and add differential and regression coverage across type checking, specialization, and runtime materialization.
Record the phase 0–8 implementation, regression traceability, retained adapters, full verification results, measured workloads, and separately scoped borrowing.
e1c02fe to
455b318
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Const evaluation rejected every borrow that carries address-space metadata. Explicit borrows of locals (`mut x`, `ref x`, and `mut` arguments) carry `Memory` metadata too, so a const fn that updated a local in place, or passed one to a helper by `mut`, failed to evaluate. Accept a `Memory` borrow whose place is rooted in a frame local and does not go through a dereference. Borrows through pointers and of provider-backed locals still fail with `InvalidProviderUse`, since constant evaluation has no memory outside its frames. A request cannot carry a pointer argument (request inputs are verified before execution), so the pointer case is tested inside the machine tests. When a frame returns a reference into itself, the value is read out if the declared result type is not a borrow, and the evaluation fails with `InvalidBorrow` if it is, so a dangling reference cannot escape. A reference into a caller's frame is returned unchanged. This fits the transactional evaluator from #1556 as is: machine references stay private to one attempt, and a blocked attempt discards its frames, so a replay after specialization starts from the original locals. #1556 recorded the borrowing restriction as intentionally kept (`docs/ctfe-deferral-audit.md`, "Borrowing scope") and pinned it with `ctfe_typed_read_preserves_provider_borrow_rejection`. That test now checks that the typed read through `ref value` evaluates to 7, under the name `ctfe_typed_read_through_frame_local_borrow_evaluates`, and the audit's borrowing paragraph describes the admitted borrows.
Const functions could not use effects at all: a `uses` clause on a `const fn` was an error, a call to any function with effects was an error, and every `with` expression in a `const fn` was rejected. A trait provider is an ordinary value, so an immutable one can be evaluated at compile time like any other argument. Allow a `const fn` to declare immutable trait effects and to supply them with `with`. During evaluation a call passes each provider as a value into the callee's effect slot, matched by the effect's binding index rather than by its position among ordinary arguments. A `with` provider that lowering captured as a place (#1564) is read from that place. The checker still rejects mutable effects, type-keyed (storage) effects, and extern functions with effects. Deferral needs no special case. Since #1556, a call whose input is still generic blocks the whole attempt, which is discarded and replayed after specialization; the replay recomputes the providers from the caller's body. Term extraction already declines calls with effect arguments, so a provider never enters a retained term. A test checks that an effectful call blocks while generic and evaluates with its provider once specialized, like a pure call. Effect slots follow the same rules as ordinary argument slots: a request that supplies no providers for an effectful function is unsupported (`NotConstEvaluable`), and a slot count or index mismatch is an invalid operation, like the existing argument arity check. The `with`-in-const-fn diagnostic (8-0056) is removed, and the two remaining const-effect messages now say what is supported.
Const evaluation rejected every borrow that carries address-space metadata. Explicit borrows of locals (`mut x`, `ref x`, and `mut` arguments) carry `Memory` metadata too, so a const fn that updated a local in place, or passed one to a helper by `mut`, failed to evaluate. Accept a `Memory` borrow whose place is rooted in a frame local and does not go through a dereference. Borrows through pointers and of provider-backed locals still fail with `InvalidProviderUse`, since constant evaluation has no memory outside its frames. A request cannot carry a pointer argument (request inputs are verified before execution), so the pointer case is tested inside the machine tests. When a frame returns a reference into itself, the value is read out if the declared result type is not a borrow, and the evaluation fails with `InvalidBorrow` if it is, so a dangling reference cannot escape. A reference into a caller's frame is returned unchanged. This fits the transactional evaluator from #1556 as is: machine references stay private to one attempt, and a blocked attempt discards its frames, so a replay after specialization starts from the original locals. #1556 recorded the borrowing restriction as intentionally kept (`docs/ctfe-deferral-audit.md`, "Borrowing scope") and pinned it with `ctfe_typed_read_preserves_provider_borrow_rejection`. That test now checks that the typed read through `ref value` evaluates to 7, under the name `ctfe_typed_read_through_frame_local_borrow_evaluates`, and the audit's borrowing paragraph describes the admitted borrows.
Const functions could not use effects at all: a `uses` clause on a `const fn` was an error, a call to any function with effects was an error, and every `with` expression in a `const fn` was rejected. A trait provider is an ordinary value, so an immutable one can be evaluated at compile time like any other argument. Allow a `const fn` to declare immutable trait effects and to supply them with `with`. During evaluation a call passes each provider as a value into the callee's effect slot, matched by the effect's binding index rather than by its position among ordinary arguments. A `with` provider that lowering captured as a place (#1564) is read from that place. The checker still rejects mutable effects, type-keyed (storage) effects, and extern functions with effects. Deferral needs no special case. Since #1556, a call whose input is still generic blocks the whole attempt, which is discarded and replayed after specialization; the replay recomputes the providers from the caller's body. Term extraction already declines calls with effect arguments, so a provider never enters a retained term. A test checks that an effectful call blocks while generic and evaluates with its provider once specialized, like a pure call. Effect slots follow the same rules as ordinary argument slots: a request that supplies no providers for an effectful function is unsupported (`NotConstEvaluable`), and a slot count or index mismatch is an invalid operation, like the existing argument arity check. The `with`-in-const-fn diagnostic (8-0056) is removed, and the two remaining const-effect messages now say what is supported.
Generic constants such as
const VALUES: [u8; N] = [7; N]were rejected whileNwas still symbolic. Preserve repeat elements and lengths as abstract constants, then materialize them after specialization. Deferred indexing keeps its bounds check, and empty arrays still evaluate their element expressions, including deferred faults.Add HIR coverage for generic records, nested and empty arrays, trait-associated lengths/elements, runtime reification, and invalid expressions. Add an execution fixture covering specialized arrays and independent mutation of repeated nested arrays.