fix: remove local macros upon parse error (#3114)

Close all groups after parse, in particular in case of parse error,
completing `Namespace`'s simulation of local definitions.

Fixes #3122

Co-authored-by: ylemkimon <y@ylem.kim>
This commit is contained in:
Erik Demaine
2021-08-28 18:59:24 -04:00
committed by GitHub
parent ff1734f7c4
commit a6f29e3612
4 changed files with 39 additions and 8 deletions

View File

@@ -3440,6 +3440,12 @@ describe("A macro expander", function() {
expect(macros["\\foo"]).toBeFalsy();
});
it("\\def doesn't change settings.macros on error", () => {
const macros = {};
expect`\def\foo{c^}\foo`.not.toParse(new Settings({macros}));
expect(macros["\\foo"]).toBeFalsy();
});
it("\\def changes settings.macros with globalGroup", () => {
const macros = {};
expect`\gdef\foo{1}`.toParse(new Settings({macros, globalGroup: true}));