nim-lang / nim-mode

An emacs major mode for the Nim programming language
137 stars 46 forks source link

smie error on simple syntax #222

Open krux02 opened 5 years ago

krux02 commented 5 years ago

In the following example, where | is the cursor position, hitting enter causes an error

echo x.type|

this is the stack trace:

Debugger entered--Lisp error: (error "Bumped into unknown token")
  signal(error ("Bumped into unknown token"))
  error("Bumped into unknown token")
  smie-indent-backward-token()
  smie-indent-after-keyword()
  run-hook-with-args-until-success(smie-indent-after-keyword)
  smie-indent-calculate()
  smie-indent-virtual()
  smie-indent--rule(:after "type" 144 nil 139)
  smie-indent-after-keyword()
  run-hook-with-args-until-success(smie-indent-after-keyword)
  smie-indent-calculate()
  (or (smie-indent-calculate) 0)
  (save-excursion (forward-line 0) (skip-chars-forward " \011") (if (>= (point) savep) (setq savep nil)) (or (smie-indent-calculate) 0))
  (condition-case err (save-excursion (forward-line 0) (skip-chars-forward " \011") (if (>= (point) savep) (setq savep nil)) (or (smie-indent-calculate) 0)) ((debug error) (message "Error: %S" err) nil))
  (or (condition-case err (save-excursion (forward-line 0) (skip-chars-forward " \011") (if (>= (point) savep) (setq savep nil)) (or (smie-indent-calculate) 0)) ((debug error) (message "Error: %S" err) nil)) 0)
  (let* ((savep (point)) (indent (or (condition-case err (save-excursion (forward-line 0) (skip-chars-forward " \011") (if (>= (point) savep) (setq savep nil)) (or (smie-indent-calculate) 0)) ((debug error) (message "Error: %S" err) nil)) 0))) (cond ((eq 'noindent indent) nil) ((assoc-default :comment nim-smie--line-info) (nim-get-comment-indent)) ((or (not (numberp indent)) (< indent 0)) 0) (t (or (assoc-default :force-indent nim-smie--line-info) indent))))
  (if empty-line-indent empty-line-indent (let* ((savep (point)) (indent (or (condition-case err (save-excursion (forward-line 0) (skip-chars-forward " \011") (if (>= (point) savep) (setq savep nil)) (or (smie-indent-calculate) 0)) ((debug error) (message "Error: %S" err) nil)) 0))) (cond ((eq 'noindent indent) nil) ((assoc-default :comment nim-smie--line-info) (nim-get-comment-indent)) ((or (not (numberp indent)) (< indent 0)) 0) (t (or (assoc-default :force-indent nim-smie--line-info) indent)))))
  (let* ((empty-line-indent (and t (assoc-default :force-indent nim-smie--line-info)))) (if empty-line-indent empty-line-indent (let* ((savep (point)) (indent (or (condition-case err (save-excursion (forward-line 0) (skip-chars-forward " \011") (if (>= (point) savep) (setq savep nil)) (or (smie-indent-calculate) 0)) ((debug error) (message "Error: %S" err) nil)) 0))) (cond ((eq 'noindent indent) nil) ((assoc-default :comment nim-smie--line-info) (nim-get-comment-indent)) ((or (not (numberp indent)) (< indent 0)) 0) (t (or (assoc-default :force-indent nim-smie--line-info) indent))))))
  nim-smie-indent-calculate()
  (and t (nim-smie-indent-calculate))
  (let* ((indentation (and t (nim-smie-indent-calculate)))) (if indentation (let ((levels (nim-indent--calculate-levels indentation))) (if previous (nim-indent--previous-level levels (current-indentation)) (if levels (apply (function max) levels) 0)))))
  nim-indent-calculate-indentation(nil)
  (and t (nim-indent-calculate-indentation previous))
  (let* ((indent (and t (nim-indent-calculate-indentation previous)))) (if indent (progn (indent-line-to indent) (run-hooks 'nim-smie-after-indent-hook))))
  (save-excursion (let* ((indent (and t (nim-indent-calculate-indentation previous)))) (if indent (progn (indent-line-to indent) (run-hooks 'nim-smie-after-indent-hook)))))
  (let ((follow-indentation-p (and (<= (line-beginning-position) (point)) (>= (+ (line-beginning-position) (current-indentation)) (point))))) (save-excursion (let* ((indent (and t (nim-indent-calculate-indentation previous)))) (if indent (progn (indent-line-to indent) (run-hooks 'nim-smie-after-indent-hook))))) (if follow-indentation-p (progn (back-to-indentation))))
  nim--indent-line-core(nil)
  nim-indent-line()
  indent-according-to-mode()
  newline-and-indent()
  funcall-interactively(newline-and-indent)
  call-interactively(newline-and-indent nil nil)
  command-execute(newline-and-indent)