Fix lua distinct with nils

This error was manifesting itself with the message:
```
skyd.Server: Merge error: skyd.ExecutionEngine: Unable to merge: [string "..."]:223: attempt to index local 'a' (a nil value)
```
and was narrowed down to specifically this code: https://gist.github.com/snormore/0ca42d67b6673e7071a8#file-gistfile1-txt-L191-L209

After some fumbling with defensive checks, this PR is the result.

@benbjohnson @matthelm