Skip to content

Fix anonymous function name collisions across files#26642

Merged
medvednikov merged 3 commits into
vlang:masterfrom
quaesitor-scientiam:fix/anon-fn-name
Feb 23, 2026
Merged

Fix anonymous function name collisions across files#26642
medvednikov merged 3 commits into
vlang:masterfrom
quaesitor-scientiam:fix/anon-fn-name

Conversation

@quaesitor-scientiam

Copy link
Copy Markdown
Contributor

Summary

Fix anonymous function name collisions across files by including pos.file_idx in the generated name. This prevents duplicate C symbols when two files emit the same anon-fn signature + position.

Before/After (generated C)

  • Before (master, no file_idx):
    insert from master build: anon_fn_7b5497f4437681ea_mut_gui__window_1728

  • After (this PR, with file_idx):
    anon_fn_7b5497f4437681ea_156_mut_gui__window_1728

Tests

  • Ran full suite (local full suite has known Windows failures: native backend + sqlite/orm).
  • Verified repro compiles:
    • .\vnew.exe -g -keepc -cc msvc -o "C:\Users\john3.vmodules\gui\examples\showcase.exe" "C:
      \Users\john3.vmodules\gui\examples\showcase.v"

@quaesitor-scientiam

Copy link
Copy Markdown
Contributor Author

Fixes issue #26641

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7efbef1d33

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread vlib/v/builder/msvc_windows.v
Comment thread vlib/v/builder/msvc_windows.v
@medvednikov

Copy link
Copy Markdown
Member

Will need a test.

@quaesitor-scientiam

quaesitor-scientiam commented Feb 22, 2026

Copy link
Copy Markdown
Contributor Author

Will need a test.

Working on it. The test runs under -prod run via the existing modules/ test harness in compiler_errors_test.v.
Is that cool?

PythonWillRule and others added 2 commits February 22, 2026 14:40
Adds a multi-file module test that verifies two anonymous functions
with identical signatures in different source files are compiled and
linked correctly after the fix in get_anon_fn_name() (PR vlang#26642).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@medvednikov medvednikov merged commit 8b4ff32 into vlang:master Feb 23, 2026
89 of 90 checks passed
@quaesitor-scientiam quaesitor-scientiam deleted the fix/anon-fn-name branch March 3, 2026 16:52
cestef pushed a commit to cestef/v that referenced this pull request Mar 9, 2026
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