Skip to content

Name anonymous functions with more details #355

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

Merged
merged 5 commits into from
Oct 4, 2019
Merged
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
9 changes: 5 additions & 4 deletions src/closure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ export default class Closure extends Callable {
return closure
}

/** Keep track how many lambdas are created */
private static lambdaCtr = 0

/** Unique ID defined for anonymous closure */
public functionName: string

Expand All @@ -88,7 +85,11 @@ export default class Closure extends Callable {
if (this.node.type === 'FunctionDeclaration' && this.node.id !== null) {
this.functionName = this.node.id.name
} else {
this.functionName = `Anonymous${++Closure.lambdaCtr}`
this.functionName =
(this.node.params.length === 1 ? '' : '(') +
this.node.params.map((o: es.Identifier) => o.name).join(', ') +
(this.node.params.length === 1 ? '' : ')') +
' => ...'
}
// TODO: Investigate how relevant this really is.
// .fun seems to only be used in interpreter's NewExpression handler, which uses .fun.prototype.
Expand Down