united-states
Is there any legal protection for actions that later become illegal?
<p>For example, lets say that being a software developer is a legal occupation right now. But 2 years from now, it becomes illegal to develop software. </p>

<ul>
<li><p>Can you be prosecuted for work that you've done in the past that has only recently become illegal?</p></li>
<li><p>Are there any legal protections / immunity currently in place to prevent this type of situation?</p></li>
</ul>

<p>This is known as a <em>retroactive</em> or <em>ex post facto</em> law. Such laws are explicitly forbidden by the US Constitution (<a href="https://en.wikipedia.org/wiki/Ex_post_facto_law" rel="noreferrer">Wikipedia</a> reference), and are generally frowned on in jurisdictions where the rule of law applies, partly because it is difficult to prove criminal intent when your action was not at the time criminal.</p>
