Skip to content

Handle missing FEN castling field without panicking#1097

Merged
codedeliveryservice merged 1 commit into
codedeliveryservice:mainfrom
grepfuldead:fix/fen-missing-castling
Jul 8, 2026
Merged

Handle missing FEN castling field without panicking#1097
codedeliveryservice merged 1 commit into
codedeliveryservice:mainfrom
grepfuldead:fix/fen-missing-castling

Conversation

@grepfuldead

Copy link
Copy Markdown
Contributor

Board::from_fen returns Err for missing placement data or an invalid active color, but unwrapped the castling field, so a FEN truncated after the active color (for example "4k3/8/8/8/8/8/8/4K3 w") panicked in the parser instead of parsing.

The trailing en passant / halfmove / fullmove fields already default via unwrap_or_default(); this makes the castling field consistent, so a missing or unrecognised castling field parses as no castling rights. Adds a regression test.

No functional change.

Bench: 2526370

@grepfuldead grepfuldead force-pushed the fix/fen-missing-castling branch 2 times, most recently from f467913 to 8989a9e Compare July 7, 2026 15:48
The trailing en passant / halfmove / fullmove fields already default via
unwrap_or_default(); this makes the castling field consistent, so a
missing or unrecognised castling field parses as no castling rights.
Adds a regression test.

No functional change.

Bench: 2931707
@grepfuldead grepfuldead force-pushed the fix/fen-missing-castling branch from 8989a9e to f80e531 Compare July 7, 2026 15:53
@codedeliveryservice codedeliveryservice merged commit 3402116 into codedeliveryservice:main Jul 8, 2026
21 checks passed
@grepfuldead grepfuldead deleted the fix/fen-missing-castling branch July 8, 2026 10: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.

2 participants