Skip to content
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

Ability to pass custom Func to CallNode #287

Closed
Dentrax opened this issue Nov 14, 2022 · 1 comment
Closed

Ability to pass custom Func to CallNode #287

Dentrax opened this issue Nov 14, 2022 · 1 comment
Labels

Comments

@Dentrax
Copy link
Contributor

Dentrax commented Nov 14, 2022

Carry: #277

Motivation

In the current implementation, you can not pass a function to CallNode directly. It’s the only option to pass a func from env; which you need to set Callee field.

Use Case

divFn := func(left, right float64) float64 {
	if right == 0 {
		panic("integer divide by zero")
	}
	return left / right
}

ast.Patch(node, &ast.CallNode{
	Func:    divFn,
	Arguments: []ast.Node{n.Left, n.Right},
})
@antonmedv
Copy link
Member

Done! Now CallNode have a Func field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants