Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const (
func (t TokenType) String() string {
types := []string{
"EOF",
"Undefined",
"TagStart",
"TagEnd",
"TagKey",
Expand Down
2 changes: 1 addition & 1 deletion pgn.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func (p *Parser) parseVariation() error {
// the last move before the variation start
variationParent = parentMove.parent
// Reset position to where the variation starts
if variationParent.parent != nil {
if variationParent.parent != nil && variationParent.parent.position != nil {
p.game.pos = variationParent.parent.position.copy()
if newPos := p.game.pos.Update(variationParent); newPos != nil {
p.game.pos = newPos
Expand Down
8 changes: 4 additions & 4 deletions polyglot.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,12 @@ func LoadFromSource(source BookSource) (*PolyglotBook, error) {

buf := make([]byte, 16)
for {
_, err := source.Read(buf)
if err == io.EOF {
_, readErr := source.Read(buf)
if readErr == io.EOF {
break
}
if err != nil {
return nil, err
if readErr != nil {
return nil, readErr
}

entry := PolyglotEntry{
Expand Down
3 changes: 2 additions & 1 deletion polyglot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package chess
import (
"bytes"
"encoding/binary"
"errors"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -60,7 +61,7 @@ func TestBytesBookSource(t *testing.T) {
// Test EOF
source.index = 32
n, err = source.Read(buf)
if err != io.EOF {
if !errors.Is(err, io.EOF) {
t.Errorf("Read() error = %v, want EOF", err)
}
}
Expand Down
Loading