lyaml
lyaml copied to clipboard
Empty mapping and empty sequence cannot be distinguished after load
Using lyaml.load() any empty (flow) mappings and sequences cannot be distinguished in the returned Lua table. Both will show up as an empty table. With minimum disruption this can be easily fixed by optionally (opts.distinct_sequence) allowing load_sequence to return {{}} in case of #sequence == 0.
I have to shoot down my own proposal. Using {{}} for an empty sequence now clashes with a singleton sequence with the empty mapping as sole element. So maybe attaching a dummy metatable to an empty table makes the distinction.
Care to propose a PR?