Local and national retailers looking to prevent mass shootings announced this past week they will restrict the sale of guns to people over the age of 21.

But those good intentions appear to run afoul of Oregon's anti-discrimination laws.

This week, Kroger announced it would stop selling guns to anyone under 21 in the 17 Fred Meyer stores that sell firearms in Oregon. Bi-Mart followed suit and promised to only sell guns to people old enough to buy a legal drink.

National department and sporting goods stores made similar decisions in the wake of the mass shooting at a Florida high school that killed 17 people. Walmart and Dick's Sporting Goods raised the minimum age to buy a gun to 21 and said they would stop selling assault-style, semi-automatic rifles.

But Jim Hargreaves, a retired Lane County judge, points out the state law that protects people from being discriminated against based on race, gender and religion. It also protects people from discrimination based on age—as long as a person is a legal adult, they can't be barred from anything that's available to the public.

And because Oregon law says that any person over 18 can buy a firearm, the stores that refuse to sell guns to 18, 19 and 20-year-olds could face legal challenges.

"They can't set their own age limit because the statute has already done that," Hargreaves says. "They don't have any authority because the statute specifically says you can't as a merchant discriminate against either young people or old people. If you're selling something you have to sell it to anyone who is entitled to buy it by law."

The Bureau of Labor and Industries, which investigates discrimination complaints, says no one has filed a formal grievance against any merchant for refusing to sell a gun since the retailers made policy changes this week.

Hargreaves says the stores that stopped selling guns to people between the ages of 18 and 20 could avoid legal battles by simply refusing to sell guns to anyone.

"I applaud them for making at least some attempt, because as flawed as it may be, at least they're trying," Hargreaves says.

He says the legislature could follow that example—since it has the power to set age restrictions on otherwise legal products.

"The legislature makes the determination of what the age limit is for doing things—they said 21 for drinking and 18 for buying guns," he says. "If you're a general merchant you don't get to change that because that's the job of the legislature."