The courts may find that an ASP, or a provision in an ASP, is outside the legislative competence of the Parliament. Such an ASP or provision would be “not law” as is stated in  section 29(1).  In other words, the effect of that decision would be that such an ASP or provision would be void ab initio i.e. it would never have had legal effect from the date of its enactment or commencement.
Similarly, the courts may find that some subordinate legislation made by Scottish Ministers is ultra vires because, for example, the power to make the legislation did not transfer to Scottish Ministers under section 53 because it was not exercised within devolved competence (section 54) or simply because the power was exercised beyond the limits of the delegated power. Again, the effect of that decision would be that such subordinate legislation would be void ab initio.
Such decisions could cause difficulty particularly if they are made some years after the ASP or the subordinate legislation has purported to come into force.  It is doubtful whether the courts have the power, at common law, to vary the retrospective effect of their decisions, such as to provide that the decision should only have effect from the date of the decision or from some date other than the date when the defective provision purported to come into force.
This section confers such a power. Such a power is thought to be necessary since the court or tribunal will, in this situation, be declaring invalid legislation (whether primary or secondary) that had, until that point, been considered to be perfectly valid.  This power affords the courts and tribunals the power to protect those who had been acting on that basis.  A court may, for example, limit any retrospective effect which its decision may have by providing that it should only take effect from the date of its decision or from some other time.  It would also allow the court to preserve the legal effects of anything already done in reliance on the erroneous provision.
This section also empowers the court to suspend the effect of its decision for any period to allow the defect to be corrected.  This would be appropriate where, for example, it was likely that the defect would be corrected by an ASP or by a remedial order under section 12 of the Convention Rights (Compliance) (Scotland) Act 2001 (asp 7) or by the UK Government in a Westminster Act or an order under section 30(2) or 107 of the Scotland Act.
In framing this section, account was taken of the similar provision in Article 172(1) of the Constitution of South Africa 1996.
Commentary Part V: Miscellaneous and General General