amazon-ion / ion-tests

Test vectors for testing compliant Ion implementations.
Apache License 2.0
27 stars 20 forks source link

Clarify whether symbols that "look like" an IVM are allowed #73

Open zslayton opened 3 years ago

zslayton commented 3 years ago

The Ion spec's Symbols section description says:

In Ion text, the Ion Version Marker (IVM) is represented by the following symbol.

$ion_1_0

This stand-alone symbol is recommended at the start of Ion text data. It identifies a specific major/minor version of the Ion notation. It resets the current symbol table to be the corresponding system symbol table, and simultaneously switches the parser into the appropriate mode for parsing the right version of Ion notation.

There is no broader discussion of Ion Version Marker syntax; in particular, no syntax is reserved for future Ion Version Markers. Readers might reasonably assume that IVMs always follow the format $ion_MAJOR_MINOR, but this is not actually provided for by the spec. The System symbols section of the spec says:

Each version of the Ion specification defines the corresponding system symbol table version. Ion 1.0 uses the "$ion" symbol table, version 1, and future versions of Ion will use larger versions of the "$ion" symbol table. $ion_1_1 will probably use version 2, while $ion_2_0 might use version 5.

suggesting that the intent was to formalize $ion_MAJOR_MINOR. However, without an explicit requirement in the spec, it is unclear whether an Ion 1.0 text reader that encountered $ion_2_0 in a stream should treat it as:

We should clarify the spec and add a test enforcing the expected behavior.

jobarr-amzn commented 3 years ago

The ion-java tests do treat $ion_MAJOR_MINOR as an IVM. See: https://github.com/amzn/ion-java/blob/0eb62ba92633f03e9f3175bb77f1b3214fcc1cdd/src/com/amazon/ion/impl/IonReaderTextUserX.java#L59

zslayton commented 2 years ago

Agreed. It's also referenced (but not defined! 😬) in the ANTLR grammar.

I think the spec should say it. As a developer, I want to be able to implement Ion by looking at the spec. I don't want to have to take a survey of the spec, ion-tests, and popular implementations to figure out what the Right Thing To Do :tm: is.