Pattern of (aa+nn*bb), matchdeclare, defmatch



I have tried to design a pattern to match such expressions as x^2+3*y^2 but failed.
It's only a practice but I am really eager to learn why it failed.

(%i1) matchdeclare([aa,bb], lambda([x], freeof("+",x)), nn, numberp);
(%o1) done

(%i2) defmatch(match1, aa);
defmatch: evaluation of atomic pattern yields: aa
(%o2) match1

(%i3) defmatch(match2, nn*bb);
(%o3) match2

(%i4) defmatch(match3, aa+nn*bb);
defmatch: nn*bb will be matched uniquely since sub-parts would otherwise be ambigious.
(%o4) match3

(%i5) match1(x^2);
(%o5) [aa=x^2]

(%i6) match1(3*y^2);
(%o6) [aa=3*y^2]

(%i7) match2(x^2);
(%o7) false

(%i8) match2(3*y^2);
(%o8) [nn=3,bb=y^2]

(%i9) match3(x^2+3*y^2);
assignment: cannot assign to nn*bb
 -- an error. To debug this try: debugmode(true);