Skip to content

Fix/promotion tag leak#116

Merged
CorentinGS merged 1 commit into
mainfrom
fix/promotion-tag-leak
Jun 2, 2026
Merged

Fix/promotion tag leak#116
CorentinGS merged 1 commit into
mainfrom
fix/promotion-tag-leak

Conversation

@CorentinGS
Copy link
Copy Markdown
Owner

No description provided.

@CorentinGS CorentinGS force-pushed the fix/promotion-tag-leak branch from 3db93e2 to 76405b9 Compare June 1, 2026 20:40
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.32%. Comparing base (90b7ea9) to head (1f1e92c).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #116      +/-   ##
==========================================
- Coverage   70.33%   70.32%   -0.01%     
==========================================
  Files          27       27              
  Lines        4187     4186       -1     
==========================================
- Hits         2945     2944       -1     
  Misses       1110     1110              
  Partials      132      132              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CorentinGS CorentinGS changed the base branch from main to feat/unsafe-moves June 1, 2026 20:42
@CorentinGS CorentinGS force-pushed the feat/unsafe-moves branch from 1a56e7a to 101cb40 Compare June 1, 2026 20:43
@CorentinGS CorentinGS force-pushed the fix/promotion-tag-leak branch from 76405b9 to cd7b24b Compare June 1, 2026 20:43
@CorentinGS CorentinGS marked this pull request as ready for review June 1, 2026 20:47
@CorentinGS CorentinGS changed the base branch from feat/unsafe-moves to main June 1, 2026 20:47
@CorentinGS CorentinGS force-pushed the fix/promotion-tag-leak branch from cd7b24b to 620aff8 Compare June 1, 2026 20:47
@CorentinGS CorentinGS requested a review from Copilot June 1, 2026 20:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a move-tag “leak” that could occur when reusing a Move struct (notably across promotion variations) by computing tags from scratch rather than mutating/accumulating them on a reused struct.

Changes:

  • Replaced addTags(*Move, *Position) with moveTags(Move, *Position) MoveTag and updated call sites to assign m.tags from a fresh computation.
  • Updated/renamed the tag-related unit test and added a regression test ensuring promotion check tags don’t carry across promotion piece types.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
notation.go Uses fresh tag computation when decoding UCI moves to avoid tag carryover.
engine.go Reworks tag computation into moveTags and updates move generation (including promotions/castling) to assign tags from scratch.
engine_test.go Renames tag test for the new API and adds regression coverage for promotion check-tag isolation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread engine.go
Comment on lines 152 to 156
} else {
m.promo = 0
addTags(&m, pos)
if m.HasTag(inCheck) == unsafeOnly {
m.tags = moveTags(m, pos)
if m.HasTag(inCheck) == unsafeOnly {
moves[count] = m
Comment thread engine_test.go Outdated
Comment on lines +233 to +236
// Position where no promotion gives check
// King on H1 is far from A8, no piece attacks it after promotion
pos := mustPosition("8/4P3/8/8/8/8/8/7K w - - 0 1")
moves := pos.ValidMoves()
@CorentinGS CorentinGS force-pushed the fix/promotion-tag-leak branch from 620aff8 to 1f1e92c Compare June 2, 2026 11:18
@CorentinGS CorentinGS merged commit 54bd13a into main Jun 2, 2026
11 checks passed
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.

2 participants