diff --git a/errors_test.go b/errors_test.go index 73b7bdc1..3703bd0e 100644 --- a/errors_test.go +++ b/errors_test.go @@ -259,6 +259,12 @@ func TestDecodeError_Position(t *testing.T) { expectedRow: 3, minCol: 5, }, + { + name: "missing equals on last line without trailing newline", + doc: "a = 1\nb = 2\nc", + expectedRow: 3, + minCol: 1, + }, } for _, e := range examples { diff --git a/unstable/parser.go b/unstable/parser.go index e2c973b5..d97dc343 100644 --- a/unstable/parser.go +++ b/unstable/parser.go @@ -345,7 +345,7 @@ func (p *Parser) parseKeyval(b []byte) (reference, []byte, error) { b = p.parseWhitespace(b) if len(b) == 0 { - return invalidReference, nil, NewParserError(b, "expected = after a key, but the document ends there") + return invalidReference, nil, NewParserError(startB[:len(startB)-len(b)], "expected = after a key, but the document ends there") } b, err = expect('=', b)