Section 29 of the Scotland Act provides that an Act or provision of an Act of the Scottish Parliament is outside its legislative competence in certain circumstances:
it would form part of the law of a country or territory other than Scotland, or confer or remove functions exercisable otherwise than in or as regards Scotland,
it relates to reserved matters,
it is in breach of the restrictions in Schedule 4, (Schedule 4 sets out ‘enactments protected from modification’ by the Scottish Parliament for example the UK Internal Market Act 2020...