Skip to content

Exclude the nameToReplace from valid capture avoidance #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: demorgan
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/lambda/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,13 @@ function replace(nameToReplace: Name, replacer: Expr, expression: Expr): Expr {
// 1: isn't free in the replacer
// 2: isn't free in the expression body
// 3: isn't captured by an intermediate function in the expression body
// 4: isn't the argument name that is being replaced.
const freeInExpressionBody = getFreeVars(expression.body).map(
(node) => node.name
);
const argNames = getAllArgumentNames(expression.body);
let newName = generateNewName(
freeInReplacer.concat(freeInExpressionBody, argNames)
freeInReplacer.concat(freeInExpressionBody, argNames, [nameToReplace])
);

// And make that the new function arg name
Expand Down