Script error 9000: Linker task graph contains a cycle

instead of
MyVariable : my_device = my_device{}

It becomes
MyVariable : ?my_device = option{my_device{}}

But you will need to do if(MyDevice:=MyVariable?): before using it in a function since to use it it must not be false.