Skip to content

(Non-)nullability should be preserved when selecting struct fields #6255

@connortsui20

Description

@connortsui20

Right now, we have a simplification rule for select expressions that turns a select of a struct into a pack of get_items of field names.

The issue with this is that get_item performs a validity intersection: Suppose the top-level struct is nullable, but the fields of the struct are non-nullable. get_item will return the intersection of the nullability, which means that a previously non-nullable field becomes nullable.

This means that evaluating select over a nullable struct with non-nullable fields will always return a struct with nullable fields, which is not correct. What we want is to essentially "mask out" the fields we do not want without changing the validity of anything.

The first fix is to fix the simplification rule to only rewrite the select as a pack when the child is already a pack. There might be other things that go wrong is the struct layout reader after that change.

CC @gatesn @joseph-isaacs @danking

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions