joaoraf / kiama

Automatically exported from code.google.com/p/kiama
GNU Lesser General Public License v3.0
7 stars 2 forks source link

initTree should be idempotent #54

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

import org.kiama.attribution._
import Attribution._

case class B() extends Attributable
case class A(b: B) extends Attributable

val root = A(B())
initTree(root)
root.children.toList

scala> root.children.toList
res1: List[org.kiama.attribution.Attributable] = List(B())

initTree(root)
root.children.toList

scala> root.children.toList
res3: List[org.kiama.attribution.Attributable] = List(B(), B())

What is the expected output? What do you see instead?

I'm expecting the list of children to stay the same even if a tree is 
initialised twice

What version of the product are you using? On what operating system?

kiama 1.3.0

Please provide any additional information below.

Concretly this shows up like this:

1. create a tree of nodes
2. initialise it with initTree
3. optimise it with some rewrite rules
4. initialise the result so that the new nodes have proper parent <-> children 
relationships

My current workaround is to do a deepClone of the tree before re-initialising 
it.

Original issue reported on code.google.com by etorrebo...@gmail.com on 16 Nov 2012 at 1:59

GoogleCodeExporter commented 9 years ago
Yep, seems to be a problem. Thanks for reporting.

Original comment by inkytonik on 16 Nov 2012 at 2:06

GoogleCodeExporter commented 9 years ago
Fixed in r23d5628876cb. Will appear in 1.4.0 with Scala 2.10.0 final but until 
then it will be in the nightlies at 
https://inkytonik.ci.cloudbees.com/job/Kiama/.

Original comment by inkytonik on 16 Nov 2012 at 9:34

GoogleCodeExporter commented 9 years ago
Thanks Tony. Is it possible to get 2.9.2 artifacts as well?

Original comment by etorrebo...@gmail.com on 16 Nov 2012 at 10:15

GoogleCodeExporter commented 9 years ago
We're not currently building across versions, but I'll look into it this 
weekend. Do you have any solution to maintaining one codebase with "import 
language.implicitConversions...." in it, but also compiling with 2.9.2?

Original comment by inkytonik on 16 Nov 2012 at 10:33

GoogleCodeExporter commented 9 years ago
For specs2 I have authorised implicit conversions as an argument to scalac:

scalacOptions ++= Seq("-deprecation", "-unchecked", "-feature", 
"-language:implicitConversions,reflectiveCalls,postfixOps,higherKinds,existentia
ls")

but I also maintain 2 distinct branches because of all the new warnings in 2.10 
plus one or two new features (which I can't remember right now).

If the only difference for you is the SIP-18 related stuff maybe you can use 2 
branches and just change the scalacOptions?

Original comment by etorrebo...@gmail.com on 17 Nov 2012 at 1:00

GoogleCodeExporter commented 9 years ago
Thanks. I've now done something similar, but I only need one branch at present. 
Our Cloudbees Jenkins page now has builds for both 2.9.2 and 2.10.0-RC2.

Original comment by inkytonik on 17 Nov 2012 at 12:46

GoogleCodeExporter commented 9 years ago
Superbe, thanks!

Original comment by etorrebo...@gmail.com on 18 Nov 2012 at 6:18

GoogleCodeExporter commented 9 years ago
Sorry to bother you again but there seems to be a problem with the 2.9.2 upload:

https://oss.sonatype.org/content/repositories/snapshots/com/googlecode/kiama/kia
ma_2.9.2/1.4.0-B4.SNAPSHOT

The jars are missing.

Original comment by etorrebo...@gmail.com on 19 Nov 2012 at 4:02

GoogleCodeExporter commented 9 years ago
Actually those things on Sonatype are an error since I didn't intend to publish 
the SNAPSHOT.

The 2.9.2 jars are on the Cloudbees project page for Kiama: 
https://inkytonik.ci.cloudbees.com/job/Kiama/.

Sorry for the confusion. I'll try to remove those empty directories.

Original comment by inkytonik on 19 Nov 2012 at 4:06

GoogleCodeExporter commented 9 years ago
Can you publish the SNAPSHOT? This is more or less mandatory for us because 
when we commit some code it gets picked up by our Jenkins server which needs to 
know where to get the SNAPSHOT jars from.

Original comment by etorrebo...@gmail.com on 19 Nov 2012 at 4:09

GoogleCodeExporter commented 9 years ago
Ok, sure, no problem. Will do as soon as I can, most likely tonight.

Original comment by inkytonik on 19 Nov 2012 at 5:46

GoogleCodeExporter commented 9 years ago
The 2.9.2 one should be there now.

Original comment by inkytonik on 19 Nov 2012 at 6:03

GoogleCodeExporter commented 9 years ago
It works fine *and* I just understood that I had a bug in the Kiama code I'm 
using for my optimiser (interestingly, it's related to losing type information 
when shuffling nodes around). That's a good day!

Original comment by etorrebo...@gmail.com on 19 Nov 2012 at 6:45