diff --git a/lib/rouge/lexers/common_lisp.rb b/lib/rouge/lexers/common_lisp.rb index 9357fa2997..4df69bb557 100644 --- a/lib/rouge/lexers/common_lisp.rb +++ b/lib/rouge/lexers/common_lisp.rb @@ -320,7 +320,7 @@ class complex concatenated-stream cons echo-stream file-stream rule /\(/, Punctuation, :root rule /\)/, Punctuation do - if stack.empty? + if stack.size == 1 token Error else token Punctuation diff --git a/spec/lexers/common_lisp_spec.rb b/spec/lexers/common_lisp_spec.rb index 4c06404363..644b472d64 100644 --- a/spec/lexers/common_lisp_spec.rb +++ b/spec/lexers/common_lisp_spec.rb @@ -18,4 +18,12 @@ assert_guess :mimetype => 'text/x-common-lisp' end end + + describe 'lexing' do + include Support::Lexing + + it 'does not crash on unbalanced parentheses' do + subject.lex(")\n").to_a + end + end end diff --git a/spec/visual/samples/common_lisp b/spec/visual/samples/common_lisp index a872b4f360..06c88db193 100644 --- a/spec/visual/samples/common_lisp +++ b/spec/visual/samples/common_lisp @@ -1,5 +1,8 @@ #nil (commented (form ftw)) +; Unmatched closing parenthesis +) + ;;;; TYPEP und Verwandtes ;;;; Michael Stoll, 21. 10. 1988 ;;;; Bruno Haible, 10.6.1989