-
Notifications
You must be signed in to change notification settings - Fork 21
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
XML comparison between Node and NodeSeq broken #3334
Comments
Imported From: https://issues.scala-lang.org/browse/SI-3334?orig=1 |
@paulp said: scala> xml == x2
res1: Boolean = false As far as I'm concerned, if we're stuck with this idea of "universal" equality and one == method which takes an Any, then the absolute minimum requirement for the standard library is that it not be internally inconsistent. That way people who want an inconsistent equals can implement it on top of a consistent one; however there is no way to implement a consistent one on top of an inconsistent one. As mentioned elsewhere the old behavior is still available in xml_==. scala> x2 xml_== xml
res0: Boolean = true
scala> xml xml_== x2
res1: Boolean = false So to the extent I have anything to say about it, this is wontfix. |
@jorgeortiz85 said: What if x2 was an Elem instead of a NodeSeq (similar to how str.reverse returns a String now)? That could solve this problem. |
@eengbrec said: scala> val x1 = <foo>bar</foo>
x1: scala.xml.Elem = <foo>bar</foo>
scala> val x2 = x1.map( i => i)
x2: scala.xml.NodeSeq = NodeSeq(<foo>bar</foo>)
scala> x2.getClass
res41: java.lang.Class[_] = class scala.xml.NodeSeq$$$$anon$$1
scala> x1.getClass
res42: java.lang.Class[_] = class scala.xml.Elem
scala> x2(0)
res43: scala.xml.Node = <foo>bar</foo>
scala> x1 == x2(0)
res44: Boolean = true
scala> x2(0) == x1
res45: Boolean = true
scala> So really it looks like the behavior of map has changed, not the behavior of equals. |
@eengbrec said: |
@paulp said:
OK, but to be clear, the behavior of equals has definitely changed. I changed it. Since NodeSeq is a Seq and therefore part of the new collections, the behavior of map has also changed. |
@paulp said:
XMLLike? The mind reels! You know that Elem's grandparent is NodeSeq, right? Everything is a sequence in XMLtown! So nothing can be Elem "instead of" NodeSeq. My effort at undoing the sequence damage was aborted, it was dug in too deep. |
@lrytz said: |
@SethTisue said: Interested community members: if you consider this issue significant, feel free to open a new issue for it on GitHub, with links in both directions. |
Old behavior:
The text was updated successfully, but these errors were encountered: