You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the first line of a file is a -- comment, an infinite loop is caused when dante-eval-block is evoked from anywhere within the corresponding comment block.
Steps to Reproduce
Write a simple config file for dante and haskell packages, saving to PATH/TO/SIMPLE/CONFIG:
Launch emacs with emacs -Q -l "PATH/TO/SIMPLE/CONFIG" "tmp.hs" (this also visits a haskell file).
Add a dante block or comment to the first line of the file and position the point anywhere on the line.
-- >>> :t [1,2,3]
Run dante-eval-block on that line (or don't---it will freeze emacs and chew up a ton of CPU).
Cause and Fix
The while condition at line 858 of dante.el always evaluates to non-nil in the case that the first line is a -- comment (and is reached by the loop).
You can verify this issue is caused by the while as follows: paste the snippet below into a new elisp buffer and run eval-last-sexp from the end of either progn expression.
--
--
--
--
(progn;; place point on the last `--` above
(beginning-of-buffer)
(forward-line3)
;; current: will enter an infinite loop
(while (looking-at"[ \t]*--") (forward-line-1)))
(progn;; place point on the last `--` above
(beginning-of-buffer)
(forward-line3)
;; corrected: stops when `forward-line` can no longer make progress
(while (and (looking-at"[ \t]*--") (eq0 (forward-line-1)))))
Thus, this issue is fixed if line 858 of dante.el is replaced by the following:
The same trick used to fix this infinite loop can also simplify block-end's while loop a few lines prior. It currently works and this is not my code base, so I won't submit a pull request for that (unless you think it would be worthwhile to do so).
The text was updated successfully, but these errors were encountered:
eppolito
added a commit
to eppolito/dante
that referenced
this issue
Nov 27, 2024
When `dante-eval-block` finds a comment at the beginning of the file, it previously entered an infinite loop. See Issue jyp#182 for a full description of the problem and code blocks to illustrate the issue and fix.
Description
When the first line of a file is a
--
comment, an infinite loop is caused whendante-eval-block
is evoked from anywhere within the corresponding comment block.Steps to Reproduce
dante
andhaskell
packages, saving toPATH/TO/SIMPLE/CONFIG
:emacs -Q -l "PATH/TO/SIMPLE/CONFIG" "tmp.hs"
(this also visits a haskell file).-- >>> :t [1,2,3]
dante-eval-block
on that line (or don't---it will freeze emacs and chew up a ton of CPU).Cause and Fix
The
while
condition at line 858 ofdante.el
always evaluates to non-nil in the case that the first line is a-- comment
(and is reached by the loop).You can verify this issue is caused by the
while
as follows: paste the snippet below into a new elisp buffer and runeval-last-sexp
from the end of eitherprogn
expression.Thus, this issue is fixed if line 858 of
dante.el
is replaced by the following:I will submit a pull request shortly.
Related Note
The same trick used to fix this infinite loop can also simplify
block-end
's while loop a few lines prior. It currently works and this is not my code base, so I won't submit a pull request for that (unless you think it would be worthwhile to do so).The text was updated successfully, but these errors were encountered: