]> www.ginac.de Git - ginac.git/commit
expairseq::match(): no side effects if match failed. Fixes spurious match failures.
authorMatthias Dellweg <dellweg@tp1.uni-duesseldorf.de>
Tue, 10 Dec 2013 08:55:28 +0000 (10:55 +0200)
committerAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Sun, 15 Dec 2013 15:22:20 +0000 (17:22 +0200)
commit9ada7a7f5c47e512b7bf6057d4c013612be9a33b
treea8b23a35efee01854257eccea1533f0623167bf3
parente5c76f659e2e882da3d5dba60502d6851f782bf3
expairseq::match(): no side effects if match failed. Fixes spurious match failures.

> match(sin(y)*exp(b)+sin(x)*exp(a), sin($0)*exp(a)+exp(b)*sin($1))
FAIL

The reason is that expairseq::match() might assign a wildcard even if
the match fails. The first attempted submatch is sin(y)*exp(b) with
sin($0)*exp(a). It fails (as it should) but $0 == y gets assigned as
a side effect (which is wrong). Next submatch is sin(x)*exp(a) with
sin($0)*exp(a) (the same pattern as in the first submatch). This one
fails because of spurious $0 == y assignment.

Due to the unpredicatable term ordering the sequence of submatches might
be different and the match might succeed (as it should). This makes
debugging a bit more funny.

Signed-off-by: Matthias Dellweg <dellweg@tp1.uni-duesseldorf.de>
[Alexei Sheplyakov: figure out the cause of the problem, make a test case]
check/match_bug.cpp
ginac/expairseq.cpp