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

Not possible to redefine functions #70

Closed
IlyaOrson opened this issue Mar 31, 2022 · 4 comments · Fixed by #72
Closed

Not possible to redefine functions #70

IlyaOrson opened this issue Mar 31, 2022 · 4 comments · Fixed by #72
Labels
bug Something isn't working

Comments

@IlyaOrson
Copy link

julia> using Infiltrator

julia> @infiltrate
Infiltrating top-level frame:

infil> test(x) = x
test (generic function with 1 method)

infil> test(x) = x
ERROR: cannot define function test; it already has a value
Stacktrace:
 [1] top-level scope
   @ none:0

Is it possible to redefine functions inside infiltrator somehow?

@IlyaOrson
Copy link
Author

Apparently it is also problematic to use any anonymous function after the first one:

julia> using Infiltrator

julia> @infiltrate
Infiltrating top-level frame:

infil> x -> x
#1 (generic function with 1 method)

infil> x -> x
ERROR: cannot declare #1#2 constant; it already has a value
Stacktrace:
 [1] top-level scope
   @ none:0

infil> x -> sin(x)
ERROR: cannot declare #1#2 constant; it already has a value
Stacktrace:
 [1] top-level scope
   @ none:0

@pfitzseb pfitzseb added the bug Something isn't working label Apr 4, 2022
@IlyaOrson
Copy link
Author

Thank you for the fix. FWIW I have noticed that sometimes the error still appears but after executing it again once or twice it disappears and everything works correctly.

@pfitzseb
Copy link
Member

Any chance you can find a reproducer for this?

@IlyaOrson
Copy link
Author

It has been tricky because every time this happens once I cannot reproduce it really.
I copy here a small example that I just stumbled upon today in case it is an useful hint for now.
I will keep an eye open for a MWE.

infil> δ_progression
47-element Vector{Float32}:
     9.0
     8.099999
     7.2899995
     6.5609994
     5.904899
     3.8742042
     3.1381054
     2.8242948
     2.5418653
     2.2876787
     2.0589108
     1.8530197
     0.98477054
     0.71789765
     0.64610785
     0.5814971
     0.5233474
     0.47101262
     0.42391136
     0.3815202
     0.41967225
     0.4616395
     0.41547555
     0.4570231
     0.5027254
     0.552998
     0.4976982
     0.547468
     0.6022148
     0.6624363
     0.59619266
     0.65581197
     0.72139317
     0.7935325
     0.7141792
     0.8641569
     0.7777412
 10717.776
     1.4769782f8
     2.035371f12
     2.8048722f16
     3.8652953f20
     5.326624f24
     7.3404295f28
     1.0115581f33
     1.3939916f37
    Inf
infil> findfirst(x -> x > 1, δ_progression)
1

infil> findfirst(x -> x > 10, δ_progression)
ERROR: cannot declare #3#4 constant; it already has a value
Stacktrace:
 [1] top-level scope
   @ none:0

infil> findfirst(x -> x > 10, δ_progression)
ERROR: cannot declare #5#6 constant; it already has a value
Stacktrace:
 [1] top-level scope
   @ none:0

infil> findfirst(x -> x > 10, δ_progression)
38

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

Successfully merging a pull request may close this issue.

2 participants