partiql-lang-kotlin
partiql-lang-kotlin copied to clipboard
[inferencer] Pathing with ordinals into ordered structs is incorrectly assigned `missing`
The inferencer incorrectly assigns the missing
type to this expression:
-
{ id : 42 }[0]
Because this is an ordered struct, the type should actually be int
.
Background:
StructType
has no notion of ordered structs and therefore the inferncer assumes that all structs are unordered. The semantic difference between ordered and unordered structs is important because pathing with ordinals works for ordered structs but always returns missing
for unordered structs, i.e.
-
{ 'id': 42 }[0]
->42
-
`{ id : 42 }`[0]
->missing
(Note: structs returned from the struct constructor are ordered while structs read from Ion literals are unordered.)
See the failing test in EvaluatorStaticTypeTests
: https://github.com/partiql/partiql-lang-kotlin/blob/fb7992468158d947557dc979f48a5f41ce83aa43/lang/test/org/partiql/lang/eval/EvaluatorStaticTypeTests.kt#L28