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

Don't accidentally extend implicit eval function #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Keno
Copy link

@Keno Keno commented Oct 17, 2024

This package uses the name eval, which is ordinarily reserved for the implicitly provided eval function provided by the core system. Adding methods to this generic function worked accidentally due to the way the implementation works, but is probably neither what you want nor guarateed to keep working (e.g. JuliaLang/julia#55949 would break it if merged). To address the issue, make Fuzzy a baremodule to avoid implicitly creating the include/eval names and then add back explicit imports of Base and a definition of include.

This way, Fuzzy.eval is completely decoupled from the core notion of eval.

This package uses the name `eval`, which is ordinarily reserved for
the implicitly provided `eval` function provided by the core system.
Adding methods to this generic function worked accidentally due to
the way the implementation works, but is probably neither what you
want nor guarateed to keep working (e.g. JuliaLang/julia#55949
would break it if merged). To address the issue, make `Fuzzy` a
baremodule to avoid implicitly creating the `include`/`eval` names
and then add back explicit imports of Base and a definition of `include`.

This way, `Fuzzy.eval` is completely decoupled from the core notion of
`eval`.
Keno added a commit to Keno/JUDI.jl that referenced this pull request Oct 17, 2024
The `eval` and `include` generic functions are implicitly provided
by `module` for every new julia module. Currently it is possible
to extend these (somewhat by accident), but this might change in
JuliaLang/julia#55949.

To avoid that causing issues, this renames the `eval` method in
this package to `eval_lazy` to avoid accidentally extending the
builtin. If desireed, you could instead use a baremodule to avoid
creating the implicit functions (see e.g. phelipe/Fuzzy.jl#21).

While I'm here, also strength-reduce the (builtin) `eval` method
to `getproperty` instead as applicable. This is not required, but
simply a best practice to avoid requiring the full semantics of
`eval` (which include arbitrary code execution) when it is not needed.

I was unable to test this locally due to some python dependency
errors, so please take a careful look to make sure I got this right.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant