[tex-k] TeX erranously expands tokens from a token variable

Wolfgang Helbig helbig at mailbox.org
Sun Aug 8 12:11:17 CEST 2021


Hi,
if you agree that this might be considered a bug by Prof. Knuth, please 
forward this mail to him:

Dear Prof. Knuth,
while working on Exercise 20.15 (A216) I might have discovered a bug:

$ cat >bug.tex
\def\b{\c\c}
\def\c{*}
\def\d{\b\c}
\toks0{\c}
\toks1\expandafter{\d}
\edef\good{\b\the\toks0 \the\toks1}
\edef\bad{\b\the\toks0\the\toks1}
\show\good
\show\bad
The \edef\good works as expected and does not expand the tokens \b\c in 
toks1.

But \edef\bad does expand the tokens in toks1 as is witnessed by the 
transcript file:

This is TeX-FPC, 4th ed. (preloaded format=plain 2021.7.21)  8 AUG 2021 
11:34
**bug
(bug.tex
 > \good=macro:
->**\c \b \c .
l.8 \show\good

?
 > \bad=macro:
->**\c ***.
l.9 \show\bad

?
)
*\bye
No pages of output.

and here is the file from the latest tex live installation I have access to.

This is TeX, Version 3.14159265 (TeX Live 2018) (preloaded format=tex)
(./bug.tex
 > \good=macro:
->**\c \b \c .
l.8 \show\good

?
 > \bad=macro:
->**\c ***.
l.9 \show\bad

?
)
*\bye

Sincerely yours,

-- 
Wolfgang Helbig
Stauferstr. 22
71334 Waiblingen
07151-920 227

Germany
-------------- next part --------------
A non-text attachment was scrubbed...
Name: helbig.vcf
Type: text/x-vcard
Size: 4 bytes
Desc: not available
URL: <https://tug.org/pipermail/tex-k/attachments/20210808/a4b29dd0/attachment.vcf>


More information about the tex-k mailing list.