hashicorp / hcl2

Former temporary home for experimental new version of HCL
https://github.com/hashicorp/hcl
Mozilla Public License 2.0
373 stars 66 forks source link

Splat on a null should return an empty sequence #66

Closed apparentlymart closed 5 years ago

apparentlymart commented 5 years ago

The splat operators already have a special case that if they are applied to a non-sequence value they behave as if the LHS was a single-element list. This is intended to make it easy to work with values that may nor may not be lists.

To complete this convenient abstraction, there should be a further special case where applying splat to a null value produces an empty tuple, thus making splat expressions a convenient way to work with values that might be null.

To avoid breaking the existing abstraction, this should apply only for null values of types we would not normally be able to iterate over. That is, a null value of list, tuple or set type should produce an error, not an empty tuple.