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

Calling a function returned by another function directly causes wrong evaluation environment #211

Open
sebffischer opened this issue Oct 19, 2024 · 2 comments
Labels
type-bug Something isn't working

Comments

@sebffischer
Copy link
Collaborator

> f = fn() {
:   a = 1
:   fn() print(a)
: }
function() {
  a <- 1
  function() print(a)
}
<environment 0x6000029303d8>
> f()()
Error: object 'a' not found
backtrace:
1: f()() => None
2: print(a) => None
3: a => None
> 
@sebffischer sebffischer changed the title Functions constructed by other functions have have the wrong environment Functions constructed by other functions have the wrong environment Oct 27, 2024
@sebffischer sebffischer added the type-bug Something isn't working label Oct 27, 2024
@sebffischer
Copy link
Collaborator Author

Interestingly, if we bind the return value first and then call the closure, it works.

> f = fn() {
:   a = 1
:   fn() a
: }
function() {
  a <- 1
  function() a
}
<environment 0x6000007bc018>
> g = f()
function() a
<environment 0x6000007bc2d8>
> g()
[1] 1
> f()()
Error: object 'a' not found
backtrace:
1: f()() => None
> f()()
> (f())()
Error: object 'a' not found
backtrace:
1: (f())() => None
> 

@sebffischer sebffischer changed the title Functions constructed by other functions have the wrong environment Calling a function returned by another function directly causes wrong evaluation argument Oct 27, 2024
@sebffischer sebffischer changed the title Calling a function returned by another function directly causes wrong evaluation argument Calling a function returned by another function directly causes wrong evaluation environment Oct 27, 2024
@sebffischer
Copy link
Collaborator Author

Maybe we assign promises the wrong environment somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant