Dynamic rule matching fails with annotations
(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 byStrategoTerm.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.
Submitted by Nathan Bruning on 2 April 2010 at 17:03this.wrapped = factory.annotateTerm(term, TermFactory.EMPTY_LIST);
Issue Log
The mentioned fix seems to solve Spoofax/65 as well.
@nathanbruning:
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