From f6020619bdf54cc4fd67bcd0152526ae0d471d5e Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Mon, 25 Nov 2024 06:03:12 +0300 Subject: [PATCH] added test showing more that forms introduced by macros do not inadvertedly capture lexical variables at use site --- examples/macro-generating-macro-2.ts.md | 30 +++++++++++++++++++++++++ tests/macro-generating-macro-2.ts | 12 ++++++++++ 2 files changed, 42 insertions(+) create mode 100644 examples/macro-generating-macro-2.ts.md create mode 100644 tests/macro-generating-macro-2.ts diff --git a/examples/macro-generating-macro-2.ts.md b/examples/macro-generating-macro-2.ts.md new file mode 100644 index 0000000..e7b6b07 --- /dev/null +++ b/examples/macro-generating-macro-2.ts.md @@ -0,0 +1,30 @@ +## `macro-generating-macro-2.ts` + +### Status: `DONE` + +### Input Program + +```typescript +using_syntax_rules( + [capture, + capture(expr, id, body), + using_syntax_rules([id, id, expr]).rewrite(body)], +).rewrite((x) => { + const using_syntax_rules = 10; + // capture introduces a using_syntax_rules form but that is + // referentially transparent .. i.e., it doesn't care about + // what's defined in its use site. Capture always works, no + // matter where you put it. + capture(x, t, (x) => x + t); +}) +``` + +### Output Program + +```typescript +(x_5) => { + const using_syntax_rules_8 = 10; + (x_13) => x_13 + x_5; +}; +``` + diff --git a/tests/macro-generating-macro-2.ts b/tests/macro-generating-macro-2.ts new file mode 100644 index 0000000..5bd59dd --- /dev/null +++ b/tests/macro-generating-macro-2.ts @@ -0,0 +1,12 @@ +using_syntax_rules( + [capture, + capture(expr, id, body), + using_syntax_rules([id, id, expr]).rewrite(body)], +).rewrite((x) => { + const using_syntax_rules = 10; + // capture introduces a using_syntax_rules form but that is + // referentially transparent .. i.e., it doesn't care about + // what's defined in its use site. Capture always works, no + // matter where you put it. + capture(x, t, (x) => x + t); +})