Brachylog, 13 9 bytes
-4 bytes thanks to a clever trickclever trick from Unrelated String
⊇.+0&s.∨Ė
Try it online! (Note that negative numbers in the input must be indicated with underscores rather than minus signs.)
Explanation
It would have been nice to use this 6-byte solution:
s.+0∨Ė
s. A contiguous sublist of the input is the output
+0 and its sum is zero
∨ Or, if it is impossible to satisfy those conditions...
Ė the output is the empty list
Unfortunately, the order in which the s
predicate tries sublists is ordered by start index, not by length. However, the ⊇
predicate, which gives not-necessarily-contiguous sublists, is ordered by length. So we can start by getting the longest sublist and then afterwards check that it's contiguous:
⊇.+0&s.∨Ė
⊇. A sublist of the input is the output
+0 and its sum is zero
& and furthermore
s. the output is a contiguous sublist of the input
∨ Or, if it is impossible to satisfy those conditions...
Ė the output is the empty list