Today I ran into a problem where the code below would work fine within Xcode 12, but on GitHub my CI/CD action would fail with "error: variable used within its own initial value".
let levels = levels(of: tree, fillWithVoidNodes: true)
levels(...) is defined in another file, so I assume that the compiler got confused by that and assumed that my
let levels assignment is circular. Or, something along those lines.
I managed to resolve this by changing the assignment
let levelStack = levels(...). However, it would be great to get some feedback on this.
- Am I wrong in declaring
levels = levels(...)?
- Is there a way to reproduce the GitHub action's error in Xcode or do I need to try compiling on the command line?
- Are there recommendations for ensuring that code is portable between different Swift environments (only Apple platforms in my case)?