On August 29, a Burlington County (New Jersey) Superior Court ruled that the winner of the June 2017 Democratic primary did not disqualify himself when he said publicly before the primary that if he won the primary, he would resign as the Democratic nominee and let the party replace him. Daniels v Williams, L-1250-17. See this story. The decision said that just because he said he wasn’t running in November doesn’t mean that he wanted people not to vote for him in the primary.
This sounds like one of those “unethical but not illegal” kind of situations.