Impossibility of performance in obligation to do

Article 1266 of the Civil Code of the Philippines discusses the exception to the obligatory force of contract referred to in Article 1159, to wit:
ART. 1266. The debtor in obligations to do shall also be released when the prestation becomes legally or physically impossible without the fault of the obligor. (1184a)
This provision is applicable only to obligations "to do", and not to obligations "to give."[1] The impossibility of performance must take place after the constitution of the obligation or during the performance of the obligation.[2][3] 

The impossibility referred in this article is either a physical or legal impossibility. Physical impossibility is present when the act by reason of its nature cannot be accomplished. For example, X obliged himself to dance in Y's birthday. However, a month before Y's birthday, X was murdered. X being dead cannot physically perform his obligation. Thus, the obligation is extinguished. On the other hand, legal impossibility refers when the act, by subsequent law, is prohibited. For example, when the contract involves selling of illegal drugs and a law is subsequently passed prohibiting the same.

Moreover, if the impossibility occurs at the time the obligation was constituted, the contract is null and void.[4] However, if the impossibility supervenes at the time of the performance, the obligation is modified or extinguished depending on whether or not it is imputable to the debtor.[5]

[1] Rabuya. (2019). Obligations and Contracts.

[2] Id.

[3] De Leon. (2014). Obligations and Contracts.

[4] Article 1348, Civil Code.

[5] Article 1266, Civil Code.