-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error recovery after missing semicolon #1025
Comments
|
I almost opened the same issue two days ago. Perhaps some smoother recovery, instead of a direct |
If a hard-end is chosen, I'd recommend Nevertheless, I think a hard-end is a bit harsh: just aborting the picture sounds more sensible (if that's reasonably doable, of course). |
Well, giving up on the path is what is already happening. The problem is that it is not possible for TikZ to detect whether giving up would cause further errors, which is usually why it starts looping. |
TeX has the 100 counter for loop detection, and if I remember correctly LaTeX has |
I think we could already fix some of these problems by making |
I found the problem. When TikZ gives up on the path it does not reinsert the token that it has scanned. In case of
During expansion TikZ absorbs \let but doesn't reinsert it which leads to \tikz@signal@path being expanded, which is an infinite loop on purpose. Now I only have to find the place where the \let has to be reinserted.
|
Okay, found the place. --- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
+++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
@@ -2436,6 +2436,7 @@
\endgroup%
\global\pgflinewidth=\tikzscope@linewidth%
\tikz@path@do@at@end%
+ \pgfutil@ifnextchar\tikz@signal@path{\let}{}%
}%
\let\tikz@lib@scope@check\pgfutil@empty% this is a hook for the scopes library
\def\tikz@path@do@at@end{\tikz@lib@scope@check}% Now I only have to find how to reinsert the previously absorbed token and how to do that only on error. |
This should now completely sidestep the looping problem and possibly other problems as well. Not happy about the --- a/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
+++ b/tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
@@ -2436,6 +2436,9 @@
\endgroup%
\global\pgflinewidth=\tikzscope@linewidth%
\tikz@path@do@at@end%
+ \expandafter\let\expandafter\tikz@expand@last@token@\csname tikz@expand@last@token\endcsname
+ \global\let\tikz@expand@last@token=\relax
+ \tikz@expand@last@token@
}%
\let\tikz@lib@scope@check\pgfutil@empty% this is a hook for the scopes library
\def\tikz@path@do@at@end{\tikz@lib@scope@check}%
@@ -2486,6 +2489,7 @@
\advance\tikz@expandcount by -1
\ifnum\tikz@expandcount<0\relax%
\tikzerror{Giving up on this path. Did you forget a semicolon?}%
+ \global\let\tikz@expand@last@token=\pgf@let@token
\let\pgfutil@next=\tikz@finish%
\else%
\let\pgfutil@next=\tikz@@expand |
looks good and a lot better than my suggestion of stopping thanks |
Co-authored-by: Henri Menke <henri@henrimenke.de>
Brief outline of the proposed feature
If the user omits a semicolon then tikz issues a quite reasonable error
! Package tikz Error: Giving up on this path. Did you forget a semicolon?.
But if you scroll past that it often ends up in a tight infinite loop so manages to run forever without filling any stack and stopping.
This is particularly troubling with systems like latexmk (and its deployment in Overleaf) as the user never sees the terminal and as the job is killed via a timout the log never gets written properly and the user is never shown the error.
I suggest below making a hard stop after the error message, this works for the Overleaf use case but maybe a bit agressive but perhaps after the error it would be possible to do a quick test if you were in a probable loop and only using
\@@end
in that case. But otherwise I think always doing a hard stop is safer than looping.I give a possible code change below but you can see the effect this has on the overleaf UI
current timeout message:
https://www.overleaf.com/read/jwbvcmsgxhzq
Modified example showing missing semicolon error
https://www.overleaf.com/read/zxzfhxjspvcq
The text was updated successfully, but these errors were encountered: