kaafir

Taking an oath that one will become a kaafir upon doing a certain action

Q: I have heard that if a person takes an oath that “If I do this or do not do this, I will become a Kafir forever”. The person becomes a kafir if he or she swore the oath with the belief that he or she would adopt kufr upon its non-fulfillment. Is this true? I would be very grateful if you could please provide a detailed answer for my satisfaction.