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

Anonymous functions cannot be defined #111

Closed
haberdashPI opened this issue Mar 22, 2024 · 6 comments
Closed

Anonymous functions cannot be defined #111

haberdashPI opened this issue Mar 22, 2024 · 6 comments
Labels
bug Something isn't working needs more info

Comments

@haberdashPI
Copy link

julia> function foo(x)
       Main.@infiltrate
       end
foo (generic function with 1 method)

julia> foo(2)
Infiltrating foo(x::Int64)
  at REPL[2]:2

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

infil>
@haberdashPI
Copy link
Author

This comes up in other ways: e.g. in some cases you can define an anonymous function once, but the second time it will complain about some anonymous variable being redefined.

@pfitzseb
Copy link
Member

pfitzseb commented Apr 8, 2024

Interesting. I can't repro this:

julia> using Infiltrator

julia> function foo(x)
       Main.@infiltrate
       end
foo (generic function with 1 method)

julia> foo(2)
Infiltrating foo(x::Int64)
  at REPL[2]:2


infil> y -> y + 2
#1 (generic function with 1 method)

infil> y -> y + 2
#3 (generic function with 1 method)

infil> y -> y + 2
#5 (generic function with 1 method)

infil> y -> y + 2
#7 (generic function with 1 method)

infil> ans
#7 (generic function with 1 method)

infil> ans(2)
4

infil> y -> y + 2
#9 (generic function with 1 method)

infil> ans(2)
4

What Julia/Infiltrator versions are you on?

@pfitzseb pfitzseb added bug Something isn't working needs more info labels Apr 8, 2024
@haberdashPI
Copy link
Author

Mmm.... I cannot reproduce this at the moment either??? It is clearly more subtle (or something got upgraded since I found this problem).

I often see related error messages when using DataFrames so I can try to whip up some more elaborate examples and see if they trigger the problem.

@haberdashPI
Copy link
Author

Okay, I can confirm that this is specific to an older version of infiltrator.

@pfitzseb
Copy link
Member

Out of curiosity: which version did this fail on?

@haberdashPI
Copy link
Author

I haven't bisected it, but I was on 1.7 when I was having issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs more info
Projects
None yet
Development

No branches or pull requests

2 participants