Skip to content

Conversation

@quaesitor-scientiam
Copy link
Contributor

Summary

  • In replace_each(), idxs.sort(a.idx < b.idx) uses b as the sort lambda parameter
  • The mut b declaration on the next line shadows it, causing the compiler to resolve b in the sort expression to the wrong variable
  • This results in an access violation crash (exit code -1073741819 / 0xC0000005) during code generation
  • Rename b/b_i to buf/buf_i to eliminate the name conflict

Test plan

  • v test vlib/builtin/ — 32 passed, 1 skipped, 0 failed
  • Verified crash no longer occurs when compiling projects that trigger replace_each

🤖 Generated with Claude Code

…shadowing

In `replace_each()`, `idxs.sort(a.idx < b.idx)` uses `b` as the sort
lambda parameter. The `mut b` declaration on the next line shadows it,
causing the compiler to resolve `b` in the sort expression to the wrong
variable, resulting in an access violation crash during code generation.

Rename `b`/`b_i` to `buf`/`buf_i` to eliminate the name conflict.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@quaesitor-scientiam quaesitor-scientiam changed the title fix: rename b to buf in string.replace_each to avoid sort lambda shadowing string: rename b to buf in string.replace_each to avoid sort lambda shadowing Feb 3, 2026
Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

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

Thank you @quaesitor-scientiam 🙇🏻 .

@spytheman spytheman merged commit 48000f4 into vlang:master Feb 3, 2026
89 checks passed
@quaesitor-scientiam quaesitor-scientiam deleted the fix/string-replace-each-sort-shadow branch February 3, 2026 10:09
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