Once, when the Israelites were in the wilderness, they came upon a man gathering wood on the Sabbath day. Those who found him as he was gathering wood brought him before Moses, Aaron, and the whole community. He was placed in custody, for it had not been specified what should be done to him. Then the Lord said to Moses, “The man shall be put to death: the whole community shall pelt him with stones outside the camp.” So the whole community took him outside the camp and stoned him to death—as the Lord had commanded Moses.
(nJPS Numbers 15:32-36)
Clearly the halakhah for gathering wood on Shabboth is that the punishment is death, but the halakhah is also that you cannot be put to death without a warning that includes the punishment.
It appears to me that the warning required by Hilkhoth Sanhedrin 12:2 could not have been administered in this case because the punishment had not yet been revealed. If that was the case, he should have only been liable for kareth. So why was he put to death?