Skip to content

fix: refuse a ragged nest of empty arrays in value set literals - #240

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
fix/ragged-nested-empty
Oct 18, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
fix/ragged-nested-empty

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #231

Problem

Value sets read a ragged nest of empty arrays as {}: Int32Set.Parse("{{{},{}},{{}}}") and "{{{}},{{},{}}}" both returned {}. PostgreSQL 16, 17 and 18 all reject them. SetFormat.IsNestOfEmptyArrays checked only that siblings reached the same depth. This hit every value set type and every entry point through SetFormat, including JSON and the TypeConverter. The behaviour is new in 10.0.0 (#128), so nothing shipped with it.

Change

The walk now builds a shape signature for each sub-array: 0 for {}, and n,child for n siblings that all have the same shape. A sibling whose shape differs ends the walk. This matches what PostgreSQL 17 and 18 read: a nest only when it is rectangular.

Measured with pg_input_is_valid(…, 'int4[]'):

Literal 16 17, 18 Library
{{{},{}},{{},{}}}, {{{{}}},{{{}}}}, {{{},{}},{{},{}},{{},{}}}, {{{{}},{{}}},{{{}},{{}}}} rejects reads {} reads {}
{{{},{}},{{}}}, {{{}},{{},{}}}, {{{},{},{}},{{},{}}}, {{{{}},{{}}},{{{}},{{},{}}}}, {{{{}},{{}}},{{{}}}} rejects rejects rejects (read {} before)

Tests

  • SetDimensionDecorationTests gains the rectangular rows (accepted) and the ragged rows (rejected). NestedEmptyArrays_ReadAsPostgres17AndLaterReadThem_AndPostgres16Rejects and the corpus probe gain both kinds too; the probe's 16/17 split set includes the new rectangular rows.
  • Depth-only walk restored: 5 unit rows fail, and on both 16 and 18, 29 live tests fail (28 value set types plus the nested-empty test). Fix in place: both pass on 16 and 18.
  • New seed ragged-nest-read-as-empty.patch (the depth-only walk). oracles.cs seeds ragged-nest reports it CAUGHT by LiteralCorpusProbeTests (28 of 49) and LiteralGrammarParityTests.
  • Core and conventions suites pass.

No changelog line: the 10.0.0 entry for #128 still says what reads, and this behaviour never shipped.

🤖 Generated with Claude Code

Value sets read {{{},{}},{{}}} and {{{}},{{},{}}} as {}, though PostgreSQL 16, 17 and 18 all
refuse them: IsNestOfEmptyArrays compared only the depth of siblings. PostgreSQL 17 and 18 read a
nest only when it is rectangular, every sibling the same shape at every level, which is now what
the walk compares (a shape signature per sub-array). Measured on 16, 17 and 18.

SetDimensionDecorationTests, LiteralGrammarParityTests' nested-empty test and the corpus probe
gain the ragged rows (refused) and the rectangular ones (read as {} on 17+, refused by 16). With the
depth-only walk restored: 5 unit rows fail, and 29 live tests on 16 and on 18.

Closes #231

Found-By: CA
Defect-Class: LIT

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.0.0 milestone Oct 18, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working silent Answers wrongly without throwing — fixes go in the next major, never deferred area/value-sets Value set families and wrapper arities area/literals Parse, TryParse and formatting package/core Affects CodoMetis.ValueRanges severity/low Cosmetic, message or documentation-level difference labels Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/literals Parse, TryParse and formatting area/value-sets Value set families and wrapper arities bug Something isn't working package/core Affects CodoMetis.ValueRanges severity/low Cosmetic, message or documentation-level difference silent Answers wrongly without throwing — fixes go in the next major, never deferred

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Value sets read a ragged nest of empty arrays as {}, which PostgreSQL refuses

1 participant