raku-mode icon indicating copy to clipboard operation
raku-mode copied to clipboard

Error: (error "Lisp nesting exceeds ‘max-lisp-eval-depth’")

Open dantecatalfamo opened this issue 4 years ago • 3 comments

This error seems to happen if you have a multi line block following a closing curly brace.

To reproduce:

{} {
<press tab here>
}

emacs perl6 error

The backtrace for this error seems to be the same SMIE functions called over and over again   —  (117 x 67) 2019-11-01 21-22-58

dantecatalfamo avatar Nov 02 '19 01:11 dantecatalfamo

I ran into the same error and messed around with raku-indent.el a little bit.

It looks like if we delete two rules in raku-smie-rules at line 58 and line 62, this particular error no longer reproduces:

diff --git a/raku-indent.el b/raku-indent.el
index 517fcea..c75f8fd 100644
--- a/raku-indent.el
+++ b/raku-indent.el
@@ -55,12 +55,7 @@
     (`(:elem . basic) raku-indent-offset)
     (`(:elem . arg) 0)
     (`(:list-intro . ,(or `";" `"")) t) ;"" stands for BOB (bug#15467).
-    (`(:before . "{")
-     (when (smie-rule-hanging-p)
-       (smie-backward-sexp ";")
-       (smie-indent-virtual)))
-    (`(:before . ,(or "{" "("))
-     (if (smie-rule-hanging-p) (smie-rule-parent 0)))))
+    ))
 
 (provide 'raku-indent)
 

I'm guessing this also breakse something else though.

gugod avatar Dec 30 '20 01:12 gugod

With a bit luck, I found that without both of those 2 rules, the indentation of if - elsestatements is changed. From:

    if %a{'foo'} {
        foo();
    } else {
        baz();
    }

... to:

    if %a{'foo'} {
        foo();
    } else {
          baz();
      }

But if we keep the rule at line 62 and only remoes the one at line 58, that's good again.

diff --git a/raku-indent.el b/raku-indent.el
index 517fcea..d3c01f5 100644
--- a/raku-indent.el
+++ b/raku-indent.el
@@ -55,10 +55,6 @@
     (`(:elem . basic) raku-indent-offset)
     (`(:elem . arg) 0)
     (`(:list-intro . ,(or `";" `"")) t) ;"" stands for BOB (bug#15467).
-    (`(:before . "{")
-     (when (smie-rule-hanging-p)
-       (smie-backward-sexp ";")
-       (smie-indent-virtual)))
     (`(:before . ,(or "{" "("))
      (if (smie-rule-hanging-p) (smie-rule-parent 0)))))
 

I've tested with my own code and some example code snippets from docs.raku.org and this seems to be good so far.

The way I tested it is via indent-region, but perhaps that does not cover all cases.

gugod avatar Dec 30 '20 01:12 gugod

Hi! Can you please submit a PR?

Altai-man avatar Jan 02 '21 08:01 Altai-man