Closed
Description
With source file like this:
-- important non-empty line
{-
-}
When point is placed after closing brace then haskell-indentation-find-indentations
throws (void-variable implicit-layout-active)
. A bit of stack trace:
(and implicit-layout-active (eq current-token (quote end-tokens)))
(cond ((and implicit-layout-active (eq current-token (quote end-tokens))) (quote end-tokens)) ((and implicit-layout-active (eq current-token (quote layout-end))) (cond ((> layout-indent (current-column)) (quote layout-end)) ((= layout-indent (current-column)) (setq current-token (quote layout-item))) ((< layout-indent (current-column)) (setq current-token (haskell-indentation-peek-token))))) ((and implicit-layout-active (eq current-token (quote layout-item))) (setq current-token (haskell-indentation-peek-token))) ((and implicit-layout-active (> layout-indent (current-column))) (setq current-token (quote layout-end))) (t (haskell-indentation-skip-token) (if (>= (point) indentation-point) (progn (setq following-token (if (= (point) indentation-point) (haskell-indentation-peek-token) (quote no-following-token))) (setq current-token (quote end-tokens))) (if (= (current-column) (haskell-indentation-current-indentation)) (progn (setq current-indent (current-column)) (setq left-indent (current-column)) (setq parse-line-number (+ parse-line-number 1)))) (cond ((and implicit-layout-active (> layout-indent (current-column))) (setq current-token (quote layout-end))) ((and implicit-layout-active (= layout-indent (current-column))) (setq current-token (quote layout-item))) (t (setq current-token (haskell-indentation-peek-token)))))))
haskell-indentation-read-next-token()
(let ((starter-column (current-column)) (current-indent current-indent) (left-indent (if (= (current-column) (haskell-indentation-current-indentation)) (current-column) left-indent))) (haskell-indentation-read-next-token) (if (eq current-token (quote end-tokens)) (progn (cond ((equal following-token end) (haskell-indentation-add-indentation starter-column)) (where-expr\? (haskell-indentation-add-where-post-indent left-indent)) (t (haskell-indentation-add-left-indent))) (throw (quote parse-end) nil))) (let* ((current-indent (current-column)) (starter-indent (min starter-column current-indent)) (left-indent (if end (+ current-indent haskell-indentation-starter-offset) left-indent))) (funcall parser) (cond ((eq current-token (quote end-tokens)) (if (equal following-token end) (progn (haskell-indentation-add-indentation starter-indent))) (if end (progn (throw (quote parse-end) nil)))) ((equal current-token end) (haskell-indentation-read-next-token)) (end (haskell-indentation-parse-error "Illegal token: %s" current-token)))))
haskell-indentation-with-starter((lambda nil (let ((implicit-layout-active nil)) (haskell-indentation-separated (function (lambda nil (let ((parser ...)) (if parser (funcall ...) (haskell-indentation-declaration))))) ";" nil))) "}")
haskell-indentation-list((lambda nil (let ((parser (assoc current-token haskell-indentation-toplevel-list))) (if parser (funcall (cdr parser)) (haskell-indentation-declaration)))) "}" ";")
(if (string= current-token "{") (haskell-indentation-list parser "}" ";") (haskell-indentation-implicit-layout-list parser))
haskell-indentation-layout((lambda nil (let ((parser (assoc current-token haskell-indentation-toplevel-list))) (if parser (funcall (cdr parser)) (haskell-indentation-declaration)))))
haskell-indentation-toplevel()
(catch (quote parse-end) (haskell-indentation-toplevel) (if (eq current-token (quote end-tokens)) nil (haskell-indentation-parse-error "Illegal token: %s" current-token)))
(if (<= indentation-point (point)) (haskell-indentation-first-indentation) (setq current-token (haskell-indentation-peek-token)) (catch (quote parse-end) (haskell-indentation-toplevel) (if (eq current-token (quote end-tokens)) nil (haskell-indentation-parse-error "Illegal token: %s" current-token))) possible-indentations)
(let ((indentation-point (point)) (layout-indent 0) (parse-line-number 0) (current-indent haskell-indentation-layout-offset) (starter-indent haskell-indentation-layout-offset) (left-indent haskell-indentation-layout-offset) (case-fold-search nil) current-token following-token possible-indentations) (haskell-indentation-goto-least-indentation) (if (<= indentation-point (point)) (haskell-indentation-first-indentation) (setq current-token (haskell-indentation-peek-token)) (catch (quote parse-end) (haskell-indentation-toplevel) (if (eq current-token (quote end-tokens)) nil (haskell-indentation-parse-error "Illegal token: %s" current-token))) possible-indentations))
(save-excursion (skip-syntax-forward "-") (let ((indentation-point (point)) (layout-indent 0) (parse-line-number 0) (current-indent haskell-indentation-layout-offset) (starter-indent haskell-indentation-layout-offset) (left-indent haskell-indentation-layout-offset) (case-fold-search nil) current-token following-token possible-indentations) (haskell-indentation-goto-least-indentation) (if (<= indentation-point (point)) (haskell-indentation-first-indentation) (setq current-token (haskell-indentation-peek-token)) (catch (quote parse-end) (haskell-indentation-toplevel) (if (eq current-token (quote end-tokens)) nil (haskell-indentation-parse-error "Illegal token: %s" current-token))) possible-indentations)))
haskell-indentation-parse-to-indentations()
(cond ((nth 3 ppss) (haskell-indentation-first-indentation)) ((nth 4 ppss) (if (save-excursion (and (skip-syntax-forward "-") (eolp) (not (> (forward-line 1) 0)) (not (nth 4 (syntax-ppss))))) (haskell-indentation-parse-to-indentations) (haskell-indentation-first-indentation))) (t (haskell-indentation-parse-to-indentations)))
(let ((ppss (syntax-ppss))) (cond ((nth 3 ppss) (haskell-indentation-first-indentation)) ((nth 4 ppss) (if (save-excursion (and (skip-syntax-forward "-") (eolp) (not (> ... 0)) (not (nth 4 ...)))) (haskell-indentation-parse-to-indentations) (haskell-indentation-first-indentation))) (t (haskell-indentation-parse-to-indentations))))
haskell-indentation-find-indentations()
Note that implicit-layout-active
is declared as dynamically bound:
(defvar implicit-layout-active)
What are the conditions when a variable can be both dynamically bound and cause void-variable
issue?
Documented in test in #853.
Metadata
Metadata
Assignees
Labels
No labels