Skip to content

when adding more than one value to a list, applying cheapDiff patch produces out of bound error #5

@eniac314

Description

@eniac314

I may have found another bug:

module CheapDiffTests exposing (..)

import Json.Decode as D
import Json.Diff as Diff exposing (..)
import Json.Encode as E
import Json.Patch as JP exposing (..)
import Json.Patch.Invertible as Inv exposing (..)

doc3 =
    E.list E.int [ 1, 2, 3, 4 ]


doc4 =
    E.list E.int [ 1, 2, 3, 4, 5, 6 ]


patch2 =
    Diff.diff doc3 doc4


cheapPatch2 =
    Diff.cheapDiff doc3 doc4 |> Inv.toMinimalPatch


val3 =
    JP.apply patch2 doc3 |> Result.toMaybe |> Maybe.map (D.decodeValue <| D.list D.int)


val4 =
    JP.apply cheapPatch2 doc3 |> Result.toMaybe |> Maybe.map (D.decodeValue <| D.list D.int)

val3 produces the correct value, val4 (when keeping the Result) gives this error: Err ("index out of bounds: 5")

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions