Wrong article submission
You should do both. Namely, send an email to the editor, explain the error and how you fixed it, and attach a revised version, and ask them how they would like to proceed. They might


Send the revised version to the referees
formally "reject" the incorrect version and consider the new version a resubmission 
reject the incorrect version and the corrected version. 


In any event, you must contact them.