090be3
t a/lib/rdoc/ruby_lex.rb b/lib/rdoc/ruby_lex.rb
090be3
index e6e0b41..da17cd5 100644
090be3
--- a/lib/rdoc/ruby_lex.rb
090be3
+++ b/lib/rdoc/ruby_lex.rb
090be3
@@ -1028,6 +1028,8 @@ def identify_here_document
090be3
     end
090be3
 
090be3
     if output_heredoc then
090be3
+      raise Error, "Missing terminating #{quoted} for string" unless l
090be3
+
090be3
       doc << l.chomp
090be3
     else
090be3
       doc << '"'
090be3
diff --git a/test/rdoc/test_rdoc_ruby_lex.rb b/test/rdoc/test_rdoc_ruby_lex.rb
090be3
index 0dcb425..56ddf60 100644
090be3
--- a/test/rdoc/test_rdoc_ruby_lex.rb
090be3
+++ b/test/rdoc/test_rdoc_ruby_lex.rb
090be3
@@ -162,6 +162,18 @@ def test_class_tokenize_heredoc_indent
090be3
     assert_equal expected, tokens
090be3
   end
090be3
 
090be3
+  def test_class_tokenize_heredoc_missing_end
090be3
+    e = assert_raises RDoc::RubyLex::Error do
090be3
+      RDoc::RubyLex.tokenize <<-'RUBY', nil
090be3
+>> string1 = <<-TXT
090be3
+>" That's swell
090be3
+>" TXT
090be3
+      RUBY
090be3
+    end
090be3
+
090be3
+    assert_equal 'Missing terminating TXT for string', e.message
090be3
+  end
090be3
+
090be3
   def test_class_tokenize_heredoc_percent_N
090be3
     tokens = RDoc::RubyLex.tokenize <<-'RUBY', nil
090be3
 a b <<-U
090be3
-- 
090be3
1.8.4