Skip to content

Handle missing FEN castling field without panicking#1097

Open
grepfuldead wants to merge 1 commit into
codedeliveryservice:mainfrom
grepfuldead:fix/fen-missing-castling
Open

Handle missing FEN castling field without panicking#1097
grepfuldead wants to merge 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

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
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.

1 participant