v2: fix self-host chain#27374
Merged
Merged
Conversation
dy-tea
pushed a commit
to wenxuanjun/v
that referenced
this pull request
Jun 19, 2026
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.
Summary
Fix the V2 self-host chain so
v -o v2 v2.v && ./v2 -o v3 v2.v && ./v3 -o v4 v2.vcompletes reliably fromcmd/v2.The fix keeps flat-mode preregistration from decoding every function body up front, avoids unsafe mutation during generated
str()function worklist iteration, avoids materializing the full expression-type list during cleanc alias collection, and prevents duplicate.vhinputs when cached headers are already present.Root Cause
The second-generation V2 compiler could corrupt or exhaust runtime state while rebuilding itself:
str()function discovery iterated a map that can be extended by recursive generation.vhfiles could be appended twice in the flat/cached pathValidation
../../v -o v2 v2.v && ./v2 -o v3 v2.v && ./v3 -o v4 v2.vfromcmd/v2./v, same self-host chain./vnew -silent test vlib/v2/ast/ vlib/v2/types/checker_flat_test.v vlib/v2/builder/target_os_test.v vlib/v2/transformer/generated_fns_parts_from_flat_test.vgit diff --check