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

Bug when function is passed an expression that contains an assignment #141

Closed
sebffischer opened this issue Jul 7, 2024 · 2 comments · Fixed by #144
Closed

Bug when function is passed an expression that contains an assignment #141

sebffischer opened this issue Jul 7, 2024 · 2 comments · Fixed by #144
Assignees

Comments

@sebffischer
Copy link
Collaborator

sebffischer commented Jul 7, 2024

> f = fn(x) x
> z = f({y = 2})
[1] 2
> z # The result  of {y = 2} is not bound to z
Error: object 'z' not found
backtrace:
> y # but the binding for y is created
[1] 2
@sebffischer sebffischer changed the title Bug when function is passed an expressino that contains an assignment Bug when function is passed an expression that contains an assignment Jul 7, 2024
@sebffischer
Copy link
Collaborator Author

This is related to the curly braces, because the same code with ( instead of { runs

@dgkf
Copy link
Owner

dgkf commented Jul 7, 2024

Poking at this I found another odd one that may be related.

f <- function(a, b) (a, b)
f({ x <- 1 }, { y <- 2 })
#> [[1]]
#> a @ <environment 0x14d1a4>
#> 
#> [[2]]
#> a @ <environment 0x14d1a4>

I’m guessing that something broke when the branches were added to support tail calls, meaning that expression results only resolve when they absolutely have to. Probably an overlooked code path.

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

Successfully merging a pull request may close this issue.

2 participants