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

Fix this bug in static compiler as well.
Merge branch 'dalen-2244_static_compiler' into stable

* dalen-2244_static_compiler:
  (#2244) Remove nil results in static compiler as well

closes #1610