The result of the Swiss immigration referendum is regrettable but it might serve to show what happens when a country votes freely for a policy that is incompatible with maintaining its current relations with the EU. The free movement of people is something that the EU will regard as non-negotiable. The rest of Switzerland’s arrangements with the EU are conditional on acceptance of that policy (the EU foresaw something like this and made it so) so all of the country’s participation in Europe, from tariff-free trade to air traffic control, is open to renegotiation. No country can pick and choose which bits of Europe it wants to participate in.
We will see what happens, but this is of course just the scenario that Catalan and Scottish nationalists are recommending.