(related to Spoofax/76 and StrategoXT/806)

Two terms “a”{“b”} do not have the same hash code if one is a StrategoString and the other is a WrappedAstNodeLink.

Problem turns out to be that WrappedAstNodeLink.hashFunction() returns the hash code with annotations of the wrapped node taken into account. This function is called by StrategoTerm.hashCode(), which takes the annotations of the wrapper into account. So the annotation modifies the hash twice.

A solution seems to be removing the annotations from the wrapped element when constructing the wrapper, which seems ok because the wrapper contains the annotations.

this.wrapped = factory.annotateTerm(term, TermFactory.EMPTY_LIST);
Submitted by Nathan Bruning on 2 April 2010 at 17:03

On 5 April 2010 at 05:43 Nathan Bruning commented:

The mentioned fix seems to solve Spoofax/65 as well.

On 6 April 2010 at 08:50 Lennart Kats commented:

Thanks for the pointer to the error in the code.

Fixed in 0.4.3 (by overriding the StrategoTerm.hashCode() implementation)

Log in to post comments