amazon-ion / ion-go

A Go implementation of Amazon Ion.
https://amazon-ion.github.io/ion-docs/
Apache License 2.0
173 stars 31 forks source link

TextReader does not error immediately when encountering a null type annotation #162

Open byronlin13 opened 4 years ago

byronlin13 commented 4 years ago
    r := NewReaderString(`null.string ::1`)
    r.Next()
    fmt.Println(r.Err())

Currently this code snippet does not return an error. This is because the text reader parses null as a symbol token and sets the current type as string. When you call r.Next() again it will parse :: as a invalid symbol and will error out.

We should read the null and check if it is an annotation by peeking forward in the stream for ::, skipping whitespaces(tabs, new lines, etc)

R-maan commented 4 years ago

A partial fix in these 2 commits: 98cf37cb27f25e53ec1e7510e34b86f82742a60f and aef586034627faedc8f205ffe577580b0092d7dd

They are not merged as this comment explains: https://github.com/amzn/ion-go/pull/158#discussion_r489079000