European Convention on Human Rights, Article 7: "No punishment without law"
1. No one shall be held guilty of any criminal offence on account of any act
or omission which did not constitute a criminal offence under national or
international law at the time when it was committed. Nor shall a heavier
penalty be imposed than the one that was applicable at the time the criminal
offence was committed.
This doesn't preclude "beneficial" retroactivity: e.g. if some act you're currently incarcerated for is declared legal henceforth (or deserves less maximum jail time that you've already served), then you should be released.