Skip to content

Commit fed1464

Browse files
authored
Fix invalid type assertion in LoadBytes (#733)
Fixes #732
1 parent 1baee46 commit fed1464

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

marshal_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4119,3 +4119,13 @@ ErrorField = "foo"
41194119
t.Fatalf("error was expected")
41204120
}
41214121
}
4122+
4123+
func TestGithubIssue732(t *testing.T) {
4124+
var v interface{}
4125+
data := []byte("a=\nb=0")
4126+
4127+
err := Unmarshal(data, &v)
4128+
if err == nil {
4129+
t.Fatalf("error was expected")
4130+
}
4131+
}

toml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ func LoadBytes(b []byte) (tree *Tree, err error) {
471471
if _, ok := r.(runtime.Error); ok {
472472
panic(r)
473473
}
474-
err = errors.New(r.(string))
474+
err = fmt.Errorf("%s", r)
475475
}
476476
}()
477477

0 commit comments

Comments
 (0)