Skip to content
This repository was archived by the owner on Nov 3, 2020. It is now read-only.
This repository was archived by the owner on Nov 3, 2020. It is now read-only.

Closures from other the global scope of other modules' free variables are not bound #19

@darkf

Description

@darkf

Since globally scoped lambdas have a special case of dynamically inheriting their modules' global scope, it uses the guest module's global scope, instead of the one the lambda was bound in.

As a test case:

import("std/list").

print(list\map(\x -> repr(x), [1, 2, 3])).

free = 42.
print(list\map(\x -> free, [1, 2, 3])).

And as a workaround, don't define them in the global scope, i.e. do:

import("std/list").

print(list\map(\x -> repr(x), [1, 2, 3])).

f() -> do
    free = 42;
    print(list\map(\x -> free, [1, 2, 3]))
end.

f().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions