blefloch / latex-unravel

Watching TeX digest tokens
24 stars 1 forks source link

Macro in that grabs \fi causes 'the-last-unravel-finished-badly' #44

Closed PhelypeOleinik closed 3 years ago

PhelypeOleinik commented 3 years ago

When a macro delimited by \fi is used in a conditional, \unravel seems to partially lose track of \if...\fi nesting and throws an error at the end:

\RequirePackage{unravel}
\def\aux\fi{}
\unravel{\ifx!!\aux\fi}
\stop

But the code execution seems to be carried out correctly.


Terminal output:

======== Welcome to the unravel package ========
    "<|" denotes the output to TeX's stomach.
    "||" denotes tokens waiting to be used.
    "|>" denotes tokens that we will act on.
    Press <enter> to continue; 'h' <enter> for help.

|| 
|> \ifx !!\aux \fi 

[===== Step 1 =====] \ifx = \ifx
|| \ifx 
|> !!\aux \fi 

[===== Step 2 =====] Compare: \ifx !!=true
|| 
|> \aux \fi 

[===== Step 3 =====] \aux = macro:\fi ->
|| 
|> 

[===== End =====]

! Package unravel Error: Internal error: 'the-last-unravel-finished-badly'. 
(unravel)                Please report.

Type <return> to continue.
 ...                                              

l.5 \unravel{\ifx!!\aux\fi}

?
blefloch commented 3 years ago

On 4/29/21 3:59 AM, Phelype Oleinik wrote:

When a macro delimited by |\fi| is used in a conditional, |\unravel| seems to partially lose track of |\if|...|\fi| nesting and throws an error at the end:

Hum, the problem is not \aux\fi, but the unfinished conditional: \unravel{\ifx aa} gives the same error. I'll take a look.

PhelypeOleinik commented 3 years ago

Duh, right, because I forgot the \fi in the definition of \aux /facepalm