(#2244) Remove nil results in static compiler as well

Fix this bug in static compiler as well.