-
Notifications
You must be signed in to change notification settings - Fork 32
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 extend implicit eval
method
#274
Conversation
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.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #274 +/- ##
==========================================
- Coverage 82.70% 78.31% -4.40%
==========================================
Files 36 36
Lines 2735 2734 -1
==========================================
- Hits 2262 2141 -121
- Misses 473 593 +120
|
@@ -10,7 +10,7 @@ JUDI.Geometry(x::JLD2.ReconstructedMutable{N, FN, NT}) where {N, FN, NT} = Geome | |||
function JUDI.tof32(x::JLD2.ReconstructedStatic{N, FN, NT}) where {N, FN, NT} | |||
# Drop "typed" signature | |||
reconstructT = Symbol(split(string(N), "{")[1]) | |||
return JUDI.tof32(eval(reconstructT)([getproperty(x, f) for f in FN]...)) | |||
return JUDI.tof32(getproperty(@__MODULE__, reconstructT)([getproperty(x, f) for f in FN]...)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return JUDI.tof32(getproperty(@__MODULE__, reconstructT)([getproperty(x, f) for f in FN]...)) | |
return JUDI.tof32(getglobal(@__MODULE__, reconstructT)([getproperty(x, f) for f in FN]...)) |
(assuming you only support v1.9 or later)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there's a 1.6 compat, which is why I used get property. But yes, getglobal is preferred for 1.9+
The
eval
andinclude
generic functions are implicitly provided bymodule
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 toeval_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 togetproperty
instead as applicable. This is not required, but simply a best practice to avoid requiring the full semantics ofeval
(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.