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

some deprecated methods in the wrong module #23146

Closed
JeffBezanson opened this issue Aug 5, 2017 · 2 comments · Fixed by #23164
Closed

some deprecated methods in the wrong module #23146

JeffBezanson opened this issue Aug 5, 2017 · 2 comments · Fixed by #23164
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) regression Regression in behavior compared to a previous version

Comments

@JeffBezanson
Copy link
Member

E.g. the vectorized method of acos_fast is in Base instead of FastMath. Caused by 7ec9b18. cc @vtjnash

I believe this is because in

macro dep_vectorize_1arg(S, f)
    x = esc(:x) # work around macro hygiene bug
    T = esc(:T) # work around macro hygiene bug
    return :( @deprecate $f($x::AbstractArray{$T}) where {$T<:$S} $f.($x) )
end

since f refers to a raw symbol, the $f is now looked up in the definition environment of the macro, which is Base. I tried to fix it by adding back f = esc(f), but the @deprecate macro doesn't like that. I usually end up with:

LoadError("sysimg.jl", 416, LoadError("deprecated.jl", 263, ErrorException("syntax: malformed \"export\" statement")))

or

LoadError("sysimg.jl", 416, LoadError("deprecated.jl", 151, ErrorException("syntax: invalid syntax (escape (outerref isambiguous))")))

I suspect both are due to not allowing multiple levels of esc wrapping.

@JeffBezanson JeffBezanson added compiler:lowering Syntax lowering (compiler front end, 2nd stage) regression Regression in behavior compared to a previous version labels Aug 5, 2017
@yuyichao
Copy link
Contributor

yuyichao commented Aug 6, 2017

Possibly related?

julia> module A
       """
       doc
       """
       f() = 1
       export f
       end
A

julia> using A

help?> f
search: f fd for fma fld fft full fld1 find filt fill fft! fdio frexp foldr foldl flush floor float first findn filt! fill! fetch FFTW fldmod findnz findin filter falses finally foreach flipdim fldmod1

  doc

help?> A.f
ERROR: UndefVarError: A not defined

Also, Compat.@dep_vectorize_* are broken.

@JeffBezanson
Copy link
Member Author

Implementing more of #10940 might be the way to go here. Basically, I think the most intuitive thing is to leave raw symbols alone as much as possible. If you put :x in an expression, the eventual output after expansion will just contain :x. Another way to look at it is that this makes the caller scope the "default", which is good because you can understand macros to a large degree by visualizing the macro output pasted at the call site.

Of course that means when a macro calls another macro, it can see (hygienic x) expressions, but something like that is probably unavoidable, and this feels like it moves the complexity to the right place.

vtjnash added a commit that referenced this issue Aug 7, 2017
vtjnash added a commit that referenced this issue Aug 7, 2017
similar to other issues mentioned in #23146
vtjnash added a commit that referenced this issue Aug 7, 2017
vtjnash added a commit that referenced this issue Aug 7, 2017
similar to other issues mentioned in #23146
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants