\(New|Renew|Provide)DocumentEnvironment does the existence check for envname without space trimming, while the actual name of environment to be defined (or redefined) is always space trimmed.
When the user-specified envname consists of leading and/or trailing space(s), it may lead to erroneously silent environment declaration.
Minimal example showing the bug
\RequirePackage{latexbug} % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}
\NewDocumentEnvironment {myenv} { } {begin} {end}
\NewDocumentEnvironment {myenv} { } {begin} {end} % errors as expected
\NewDocumentEnvironment { myenv } { } {begin} {end} % !! works, which is wrong
\begin{document}
\end{document}
Brief outline of the bug
\(New|Renew|Provide)DocumentEnvironment
does the existence check forenvname
without space trimming, while the actual name of environment to be defined (or redefined) is always space trimmed.When the user-specified
envname
consists of leading and/or trailing space(s), it may lead to erroneously silent environment declaration.Minimal example showing the bug
Log file (required) and possibly PDF file
ltcmd-env-exisistence-check.log
Relevant source lines
https://github.com/latex3/latex2e/blob/066ad1dd36a904d8b56f799bc30830416c62305f/base/ltcmd.dtx#L5030-L5047 https://github.com/latex3/latex2e/blob/066ad1dd36a904d8b56f799bc30830416c62305f/base/ltcmd.dtx#L629-L633