fix bug in definition lookup within pattern