Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To JSON conversion: Delete causes exception #19

Closed
Tamriel opened this issue Jan 25, 2017 · 3 comments · Fixed by #20
Closed

To JSON conversion: Delete causes exception #19

Tamriel opened this issue Jan 25, 2017 · 3 comments · Fixed by #20

Comments

@Tamriel
Copy link
Contributor

Tamriel commented Jan 25, 2017

import eu.timepit.crjdt.circe.RegNodeConflictResolver.LWW
import eu.timepit.crjdt.circe.syntax._
import eu.timepit.crjdt.core.Replica
import eu.timepit.crjdt.core.syntax._

object Playground {

  def main(args: Array[String]): Unit = {
    var p = Replica.empty("p")
    val list = doc.downField("list")
    p = p.applyCmd(list := `[]`)
    p = p.applyCmd(list.iter.insert("1"))
    p = p.applyCmd(list.iter.next.insert("2"))
    p = p.applyCmd(list.iter.next.delete) // it works without this line
    println(p.document.toJson)
  }
}

@TanUkkii007: The above code causes

Exception in thread "main" scala.MatchError: (RegT(IdK(Id(2,p))),RegNode(Map())) (of class scala.Tuple2)
	at eu.timepit.crjdt.circe.NodeToJson$$anonfun$listToJson$1.apply(NodeToJson.scala:50)
@TanUkkii007
Copy link
Contributor

Thanks for reporting!
I will check it in the weekend.

@TanUkkii007
Copy link
Contributor

(RegT(IdK(Id(2,p))),RegNode(Map()))

It seems the document state has empty register. Could be related to #15 .

@TanUkkii007
Copy link
Contributor

Will be fixed on #20 .
The reason of the MatchError is wrong usage of foreach with PartialFunction filtering items that are not present.
No relation to #15 .

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 a pull request may close this issue.

2 participants