There’s a strange myth circulating in Catholic circles that a priest cannot refuse a sacrament to somebody who asks for it, that somehow there exists a fundamental “right” to the sacraments.
This is not accurate.
Here’s what Canon Law really says:
Can. 843 §1. Sacred ministers cannot deny the sacraments to those who seek them at appropriate times, are properly disposed, and are not prohibited by law from receiving them.
Did you get that last part? It means that there are conditions that must be met before someone can receive a sacrament. The #1 condition, of course, is that you must be baptized before you can receive any other sacrament. But there are more.
Can you receive absolution if you haven’t repented? Can you be married if you don’t want children? Can you receive communion if you were eating a Big Mac during the Agnus Dei?
There are obviously many conditions that could disqualify someone. It just doesn’t make sense to speak of a “right” to the sacraments, not in the way the word “right” is commonly used today.
Read Fr. Z’s explanation here.