swift-emacs / swift-mode

Emacs support for Apple's Swift programming language.
GNU General Public License v3.0
363 stars 47 forks source link

Lisp nesting exceeds ‘max-lisp-eval-depth’ error #169

Open galeo opened 3 years ago

galeo commented 3 years ago

When trying to call functionjit-lock-fontify-now, this errror will occur.

Here is the backtrace log:
Debugger entered--Lisp error: (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")
  #f(compiled-function (matched names) #)(nil #)
  #f(compiled-function (elt) #)(#)
  mapc(#f(compiled-function (elt) #) (# #))
  seq-do(#f(compiled-function (elt) #) (# #))
  seq-reduce(#f(compiled-function (matched names) #) (# #) nil)
  #f(compiled-function (pos limit) #)(7758 18354)
  swift-mode:font-lock-match-expr(18354 #f(compiled-function (pos limit) #))
  swift-mode:font-lock-match-expr(18354 #f(compiled-function (pos limit) #))
  swift-mode:font-lock-match-expr(18354 #f(compiled-function (pos limit) #))
  swift-mode:font-lock-match-expr(18354 #f(compiled-function (pos limit) #))
  ...
  ....[lots of same lines]...
  ....
  swift-mode:font-lock-match-expr(18354 #f(compiled-function (pos limit) #))
  swift-mode:font-lock-match-expr(18354 #f(compiled-function (pos limit) #))
  swift-mode:font-lock-match-expr(18354 #f(compiled-function (pos limit) #))
  swift-mode:font-lock-match-builtin-enum-case-names(18354)
  font-lock-fontify-keywords-region(1519 18354 nil)
  font-lock-default-fontify-region(1519 18354 nil)
  font-lock-fontify-region(1519 18354)
  #f(compiled-function (fun) #)(font-lock-fontify-region)
  run-hook-wrapped(#f(compiled-function (fun) #) font-lock-fontify-region)
  jit-lock--run-functions(1519 18354)
  jit-lock-fontify-now()

Restart emacs, and when it tries to restore the previously opened swift file, it will freeze. By executing the C-g key serveral times, it will return to normal, and there will be the following output in *Messages* buffer:

Error during redisplay: (internal--syntax-propertize 1442) signaled (quit)
Error during redisplay: (internal--syntax-propertize 4000) signaled (quit)
Error during redisplay: (internal--syntax-propertize 6042) signaled (quit)
Error during redisplay: (internal--syntax-propertize 8248) signaled (quit)
Error during redisplay: (internal--syntax-propertize 10546) signaled (quit)
Error during redisplay: (internal--syntax-propertize 12685) signaled (quit)
Error during redisplay: (internal--syntax-propertize 14710) signaled (quit)
Error during redisplay: (internal--syntax-propertize 16795) signaled (quit)
taku0 commented 3 years ago

Thank you for reporting. Fixed by 5597eafa55934c67185e627c362663753f695865, hopefully.
The fix will soon be deployed to MELPA in few days. Could you try it from MELPA or master branch?

galeo commented 3 years ago

Thanks for the fix. It works well when trying to call jit-lock-fontify-now. However, emacs still freezes when trying to restore the previously opened swift file at startup. Act as before, the *Messages* buffer will have a slight difference in output:

Error during redisplay: (internal--syntax-propertize 1437) signaled (quit)
Error during redisplay: (internal--syntax-propertize 3799) signaled (quit)
Error during redisplay: (internal--syntax-propertize 5863) signaled (quit)
Error during redisplay: (internal--syntax-propertize 7962) signaled (quit)
Error during redisplay: (internal--syntax-propertize 10068) signaled (quit)
Error during redisplay: (internal--syntax-propertize 12188) signaled (quit)
Error during redisplay: (internal--syntax-propertize 14213) signaled (quit)
Error during redisplay: (internal--syntax-propertize 16298) signaled (quit)

The swift file used for testing is the same. I don't know how to debug this problem.

taku0 commented 3 years ago

I guess font-locking is just slow. I have no idea how to improve it.