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

[internals] Detect immediatly applied funs and change the error message accordingly #2

Open
Shakadak opened this issue Oct 21, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@Shakadak
Copy link
Owner

investiguate this strange data

  1) test view with anonymous function, wrong arg (AnonymousFunctionViewTest)
     test/anonymous_function_view_test.exs:86
     ** (CaseClauseError) no case clause matching: {[1, 2, 3]}
     code: view [1, 2, 3] do
     stacktrace:
       test/anonymous_function_view_test.exs:90: (test)

Should display [1, 2, 3] instead of the same but wrapped in a 1-tuple.

@Shakadak Shakadak self-assigned this Oct 21, 2021
@Shakadak Shakadak added the bug Something isn't working label Oct 21, 2021
@Shakadak
Copy link
Owner Author

Shakadak commented Oct 21, 2021

When an anonymous function is defined and then immediately applied (fn x -> x + 1).(0), if it is compiled code, then the Erlang VM executes it as a case. (Explaining the wrapping in a tuple, as that's how I did it for a custom def)
So nothing can be done on my end, and it's plenty normal.

@Shakadak
Copy link
Owner Author

Shakadak commented Nov 3, 2021

erlang/otp#4545

@Shakadak
Copy link
Owner Author

Shakadak commented Nov 3, 2021

Detect this case and unwrap the values to raise error similar to Elixir

@Shakadak Shakadak reopened this Nov 3, 2021
@Shakadak Shakadak added enhancement New feature or request and removed bug Something isn't working labels Nov 3, 2021
@Shakadak Shakadak changed the title [internals] improper data in anonymous function view [internals] Detect immediatly applied funs and change the error message accordingly Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant