Skip to content

Conversation

@michallepicki
Copy link
Contributor

@michallepicki michallepicki commented Nov 29, 2025

See #14837 (comment)

As mentioned on #14928, this has a small performance cost. Alternatively the spec of Code.eval_quoted can be changed to be "open"

edit: Actually, I think EEx.eval_file is probably not warning thanks to Keyword.put_new here

### Helpers

defp do_eval(compiled, bindings, options) do
options = Keyword.new(options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is simply hiding the options, right? Wouldn't it be better if we called Keyword.split or Keyword.pop as we do in other places?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I was saying in the comment mentioned above, we're a bit lying to ourselves because Dialyzer doesn't really follow the logic of Keyword.pop.
Calling any function (even Function.identity) is equivalent to type-laundering and returns a broader type.
The real type of these functions is actually "open" keywords, where unknown keys are just ignored.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻 Keyword.pop is also effectively only hiding the options. But I agree it would be better, I think it also makes the code more readable/intentional

I think here the difference is that we cannot easily take the "local" options because EEx compile_opts are "open" on purpose, I think custom EEx engines options can be arbitrary keys? But we could take the remote opts before calling Code.eval_quoted, should I do that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, calling take would be the way to go then!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@michallepicki michallepicki changed the title Fix dialyzer warnings on EEx.eval_string and EEx.eval_file Fix dialyzer warnings on EEx.eval_string Nov 29, 2025
@michallepicki michallepicki force-pushed the michal/25-11-29-eex-dialyzer branch from 5d15496 to 9ac5f3b Compare November 29, 2025 10:45
@josevalim josevalim merged commit 31ec8cc into elixir-lang:main Nov 29, 2025
12 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants