Skip to content

Add snapshot cases for finding base slices on the type-slicing path - #290

Open
AltangerelG wants to merge 1 commit into
FHIR:masterfrom
AltangerelG:test-cases/base-slices-index
Open

AltangerelG wants to merge 1 commit into
FHIR:masterfrom
AltangerelG:test-cases/base-slices-index

Conversation

@AltangerelG

Copy link
Copy Markdown

Split out of #288, one case per fix as @grahamegrieve asked.

Covers hapifhir/org.hl7.fhir.core#2585,
fixed by PR #2662.

Two cases, because the review turned up that the guard I first proposed was treating a
symptom:

  • empty-base-slices — the base slices Observation.value[x] by type but declares no
    named slice. Nothing is found, and the base cursor has to fall back to the slicer's own
    scope.
  • sliced-base-with-children — the base declares a named slice and constrains a
    child of the unsliced element, so the child rows sit between the slicing entry and the
    slice. This is the one that shows the real defect: findBaseSlices was being given the
    slicer's last child instead of the slicer, so the named slice was never found.

Both fail on core master with

Exception generating snapshot for …: Index -1 out of bounds for length 0

in r5 and in r6, and both pass with #2662. Expected files were generated by the fixed code
and then checked against master.

@grahamegrieve grahamegrieve left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update so that not every line of the manifest is changed

processPathWithSlicedBaseWhereDiffsConstrainTypes passes an index to
findBaseSlices, which wants the slicer's own index: it skips the
slicer's children and then collects the named slices that follow.

empty-base-slices covers a base slicer with no named slice rows at all.
sliced-base-with-children covers a base that declares a named slice and
also constrains a child of the unsliced element, so the child rows sit
between the slicing entry and the slice.

Both fail on org.hl7.fhir.core master with "Index -1 out of bounds for
length 0", in r5 and in r6, and pass with
hapifhir/org.hl7.fhir.core#2662.

For hapifhir/org.hl7.fhir.core#2585.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@AltangerelG
AltangerelG force-pushed the test-cases/base-slices-index branch from 8cffe65 to b999dd3 Compare September 28, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants