Prolog: fixing bug #2057.