Repository navigation
Fix query-cycle panic on const blocks with generic calls in parameter types - #1669
Merged
Merged
Conversation
`fn f(a: Holder<{ id<5>() }>::Out, b: Holder<{ id<5>() }>::Out)` made
the compiler panic with a query cycle. Building f's parameter list
lowers its parameter types. Resolving `::Out` type-checks the const
block, which evaluates the `5` in `id<5>`. That evaluation built its
capture environment up front, which asks for f's parameter list again.
Since #1535 the capture environment is built at the start of
evaluate_const_ty, even for a literal or arithmetic that never reads
it. Build it on first use instead. The value is the same wherever it
is used, so results do not change; only the needless dependency goes
away. A const block passed as a generic argument inside such a
parameter type (`id<{ id<5>() }>`) still needs the environment and
still cycles; that is left for a separate change.
micahscopes
force-pushed
the
fix/const-arg-cycle
branch
from
September 30, 2026 21:42
17a388a to
a10acf2
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.
This snippet makes
fe checkpanic with a query cycle (param_schema):What cycled. Building
f's parameter list lowers its parameter types. Resolving::Outtype-checks the block{ id<5>() }, which evaluates the5inid<5>.evaluate_const_tybuilt that constant's capture environment (theenclosing function's parameters) at its start, and that asks for
f's parameter list again. The literal never readsthe environment.
The fix. Build the capture environment on first use. It is still built, with the same value, wherever it is read:
generic parameter lookup, trait and inherent consts, and CTFE. Evaluations that never read it no longer depend on the
owner's parameter list. No check changes. The same change fixes trait methods of this shape, which hit an
index-out-of-bounds panic in
param_schema.One case still cycles: a const block passed as a generic argument inside such a type, e.g.
Holder<{ id<{ id<5>() }>() }>::Outtwice. That inner block needs the environment for evaluation, so it needs adifferent fix, which I've left out of this PR.
Tests. New ty_check uitests:
const-path arguments, aliases and fields; it is also run through
fe checkincrash_regressionsBoth panicked before this change.
This follows up #1535; thanks for the generic defaults work.