Assets and ALGOs lost forever if app deleted without closing out


I noticed that if we delete an app without closing out the assets and the algo balance, the assets and ALGOs are lost forever with no way to recover them.
I found this post of @fabrice confirming this.

This is IMO an issue as on Mainnet there will always be errors/bugs in some smart contracts and :

  • lot of people will lose their assets and/or ALGOs forever
  • progressively this will decrease the total supply of ALGOs

An easy solution is to forbid deleting an app if there is still an asset or ALGOs remaining in the app account.

What do you think ?

I agree this is a risk.
On the other hand, there are many other ways for a badly written smart contract to lose assets.

What do you think of having a static analyzer able to display a warning when such a risk occurs? Such a static analyzer would also check for other dangerous behaviors.

Yes why not but it should be complementary.
Preventing the deletion of the app at runtime if it’s account is not empty avoids 100% of the losses for this case. Other cases could be catched by static analysis (partially).