Check that expr is Expr before matching it

Fixes issue #2711