Skip to content

Fix checklocks return position for func literals#13270

Open
Haihan-Jiang wants to merge 1 commit into
google:masterfrom
Haihan-Jiang:codex/gvisor-checklocks-return-pos
Open

Fix checklocks return position for func literals#13270
Haihan-Jiang wants to merge 1 commit into
google:masterfrom
Haihan-Jiang:codex/gvisor-checklocks-return-pos

Conversation

@Haihan-Jiang
Copy link
Copy Markdown

Fixes #11203.

What

  • Use the enclosing function literal position when an SSA return has no source position.
  • Apply that return position consistently to checklocks return diagnostics and forced-failure matching.
  • Add a regression test for an anonymous deferred function whose implicit return leaves a lock held.

Why

Implicit returns from anonymous functions can have token.NoPos in SSA. checklocks then reports diagnostics at -, making it hard to identify the offending defer.

Testing

  • git diff --check
  • bazel test //tools/checklocks/test:test_nogo --test_output=all
  • bazel test //tools/checklocks/...

@Haihan-Jiang Haihan-Jiang marked this pull request as ready for review May 24, 2026 09:20
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.

[checklocks]: source file and line number sometimes not printed

1 participant