Lawmakers in Oklahoma Thursday moved to close a loophole in state law that allowed a 17-year-old boy to walk free after prosecutors accused him of forcing a heavily intoxicated girl to perform a sex act.

The Oklahoma Court of Criminal Appeals pointed out that while the state's rape law addresses unconscious or intoxicated victims, the forcible sodomy law does not. Prosecutors called the ruling “insane” and “offensive.”

The case involved two Tulsa high school students who had been drinking in a park in 2015, Fox 23 Tulsa reported. A forcible sodomy conviction could have put the teen behind bars when he turned 19 and was no longer eligible for youthful offender status.

Prosecutors had charged him with forcing a 16-year-old girl who was passed out drunk to perform oral sex. He had also been accused of rape but that charge was dropped because of a lack of evidence, according to Oklahoma Watch, a nonprofit journalism website, which first reported on the ruling.

“The Legislature’s inclusion of an intoxication circumstance for the crime of rape…is not found in the five very specific requirements of forcible sodomy," the appeals court wrote.

Tulsa prosecutor Benjamin Fu told Oklahoma Watch the court’s interpretation was “insane,” “dangerous” and “offensive.”

Fu also spoke to Fox 23. “My concern here is the court is now saying that there is a separate class of victims and those are intoxicated victims,” he told the station.

“I don’t believe for a moment that the court, if she suffered a medical seizure, or low blood, or some other condition that caused her to become unconscious and the same act happened, that anyone would stop for a moment and say is that illegal,” he said.

Republican State Rep. Scott Biggs, a former prosecutor, said he was "horrified" by last month's decision and is drafting language that legislators could consider as early as next week.

"I think the judges made a grave error, but if they need more clarification, we are happy to give it to them by fixing the statute," he said.

Click here for more from Fox 23 Tulsa.

The Associated Press contributed to this report.