Repository navigation
Conversation
… parameters `handleGenericInvocation` substituted only `tyGenericParam` arguments before searching the instance cache again, so for `B[n]` with a `static` parameter every instantiation created a new `B[3]`. The duplicate instance in the caller had no lifted hooks: `genSink` found no `=sink` and its fallback destroyed `b` before `f(g(b))` read it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Like genOp, so a structurally equal duplicate of a type without its own hooks does not take the destroy-first fallback (bug #26680). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes tests/metatype/tmatrix4.nim: for implicit generics a static parameter can be bound to its base type, which turned `TVector[T, C]` into `TVector[float32, int]`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
fixes #26680
This is related to static generic parameters, but not in
injectdestructors:handleGenericInvocationsubstitutes onlytyGenericParamarguments of an invocation before it searches the instance cache a second time. InB[n],nis an unresolvedtyStatic, so nothing is substituted, the second search is skipped and each instantiation produces a freshB[3](11 instances for the test case).B[3]ref and to thetyGenericInst, but the inner ref of the duplicate thatbhas gets none.genSinklooks the op up on that ref without the canonical-type fallback thatgenOphas, finds no=sinkand takes the=destroy(dest); dest = ripath.deepAliasesdoesn't see the read ofbin:tmpD = g(b), sobis freed beforeg(b)reads it.The fix substitutes unresolved
staticarguments too (only when they are bound, so a plainstatic[int]is left alone). With that there is a singleB[3]instance and=sinkis found.In addition
genSinknow uses the same canonical-type fallback asgenOp(factored out asfindOp), so a duplicate instance that slips through some other way no longer takes the destroy-first path. Each of the two changes fixes the test case on its own.🤖 Generated with Claude Code