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

Restart reason: Change in binding resolution #239

Open
Keno opened this issue Feb 1, 2019 · 2 comments
Open

Restart reason: Change in binding resolution #239

Keno opened this issue Feb 1, 2019 · 2 comments
Labels
julialimit Feature requires changes to julia

Comments

@Keno
Copy link
Collaborator

Keno commented Feb 1, 2019

Say you accidentally write something like this in a package:

foo() = iterate(...)
iterate(a::Foo) = ...

The second definition is wrong. What was intended was to extend Base.iterate. Now, if I add the missing Base., revise will delete the method, but the binding in foo will still resolve to the (now methodless) iterate function in my module. Not sure this can be addressed in the near term, but wanted to document it as a reason I had to restart my session.

@timholy
Copy link
Owner

timholy commented Feb 1, 2019

Interesting. The rewrite I'm getting started on now, based on lowered code (JuliaDebug/ASTInterpreter2.jl#32), offers an opportunity to fix this via backedges. Your timing was fortuitous.

timholy added a commit that referenced this issue Apr 6, 2019
@timholy
Copy link
Owner

timholy commented Apr 6, 2019

I have a "fix" for this in the branch teh/bindings, but there's one teeny problem. I think I was fooled by the fact that you can do

julia> first = 0
0

julia> first = Base.first
first (generic function with 24 methods)

but when you try this with functions:

julia> struct Iter end

julia> iterate(i::Iter) = i, nothing
iterate (generic function with 1 method)

julia> iterate(i::Iter, ::Any) = nothing
iterate (generic function with 2 methods)

julia> mths = methods(iterate)
# 2 methods for generic function "iterate":
[1] iterate(i::Iter) in Main at REPL[2]:1
[2] iterate(i::Iter, ::Any) in Main at REPL[3]:1

julia> Base.delete_method(mths.ms[1])

julia> Base.delete_method(mths.ms[2])

julia> iterate = Base.iterate
ERROR: invalid redefinition of constant iterate
Stacktrace:
 [1] top-level scope at none:0

Know of any workaround?

@timholy timholy added the julialimit Feature requires changes to julia label Nov 22, 2019
timholy added a commit that referenced this issue Nov 22, 2020
Closes #579

This doesn't address #239, since any internal references to the name
still refer to the old binding.
timholy added a commit that referenced this issue Nov 22, 2020
Closes #579

This doesn't address #239, since any internal references to the name
still refer to the old binding.

Also:
* Use do_test in empty env test
* Remove debugging cruft from MacroLineNos568
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
julialimit Feature requires changes to julia
Projects
None yet
Development

No branches or pull requests

2 participants