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

Capture referenced bindings in anonymous functions #50

Open
fuelen opened this issue Jul 17, 2023 · 0 comments
Open

Capture referenced bindings in anonymous functions #50

fuelen opened this issue Jul 17, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@fuelen
Copy link
Contributor

fuelen commented Jul 17, 2023

Describe the bug
Spark doesn't capture referenced bindings in generated functions.

To Reproduce

        presets do
          for {name, message} <- [{:bend, "stuff"}, {:start_casino, "with fun stuff"}] do
            preset name do
              default_message(message)

              contacter(fn message1 ->
                "#{message1}: #{unquote(message)}"
              end)
            end
          end
        end

error:

** (CompileError) test/dsl_test.exs:74: undefined function message/0 (there is no such import)

Expected behavior
Presence of referenced bindings in anonymous functions should generate different anonymous functions depending on the actual value of the binding.

Runtime

  • Spark version: latest

Additional context
Link to conversation in Discord.

@fuelen fuelen added the bug Something isn't working label Jul 17, 2023
fuelen added a commit to fuelen/seed_factory that referenced this issue Jul 23, 2023
Currently, there are limitations in Spark library and it is not possible
to write this code:
```elixir
for {field, value} <- [a: 1, b: 2, c: 3] do
  param field, fn -> value end
end
```
details are here: ash-project/spark#50
fuelen added a commit to fuelen/seed_factory that referenced this issue Jul 24, 2023
Currently, there are limitations in Spark library and it is not possible
to write this code:
```elixir
for {field, value} <- [a: 1, b: 2, c: 3] do
  param field, fn -> value end
end
```
details are here: ash-project/spark#50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant