diff --git a/lib/haml/exec.rb b/lib/haml/exec.rb
index <HASH>..<HASH> 100644
--- a/lib/haml/exec.rb
+++ b/lib/haml/exec.rb
@@ -58,8 +58,8 @@ module Haml
         # SyntaxErrors have weird line reporting
         # when there's trailing whitespace,
         # which there is for Haml documents.
-        return exception.message.scan(/:(\d+)/).first.first if exception.is_a?(::SyntaxError)
-        exception.backtrace[0].scan(/:(\d+)/).first.first
+        return (exception.message.scan(/:(\d+)/).first || ["??"]).first if exception.is_a?(::SyntaxError)
+        (exception.backtrace[0].scan(/:(\d+)/).first || ["??"]).first
       end
 
       # Tells optparse how to parse the arguments
Make executables still raise errors even if there's no line number to be found.