Using Deprecations.jl (and more generally on updating syntax)

Hi all,

I’m in the process of upgrading some v0.5 code to v0.7. For various reasons this code is on a local machine rather than a GitHub repository, so FemtoCleaner is not an option (that I’m aware of - maybe there is a way to use it locally?).

Instead, I’ve cloned Deprecations.jl and was hoping to use the edit_text and edit_file functions in this package. However, I can’t get the package to load on either v0.6 or v0.7. Note, for both versions, I checked out both AbstractTrees and CSTParser so they’re on master. The issue appears to be in Deprecations itself. Specifically, when using Deprecations, I get the following error:

ERROR: LoadError: LoadError: LoadError: TypeError: in Type{…} expression, expected UnionAll, got Type{CSTParser.OPERATOR}
Stacktrace:
[1] include_relative(::Module, ::String) at ./loading.jl:464
[2] include at ./sysimg.jl:14 [inlined]
[3] include(::String) at /home/colin/.julia/v0.7/Deprecations/src/Deprecations.jl:1
[4] include_relative(::Module, ::String) at ./loading.jl:464
[5] include at ./sysimg.jl:14 [inlined]
[6] include(::String) at /home/colin/.julia/v0.7/Deprecations/src/Deprecations.jl:1
[7] include_relative(::Module, ::String) at ./loading.jl:464
[8] _require(::Symbol) at ./loading.jl:401
[9] require(::Symbol) at ./loading.jl:318
while loading /home/colin/.julia/v0.7/Deprecations/src/database/versioncompare.jl, in expression starting on line 54
while loading /home/colin/.julia/v0.7/Deprecations/src/database.jl, in expression starting on line 9
while loading /home/colin/.julia/v0.7/Deprecations/src/Deprecations.jl, in expression starting on line 71

The line that is causing the problem follows:

opcode(x::EXPR{CSTParser.OPERATOR{6,op,false}}) where {op} = op

I’m not too familiar with UnionAll or how it works (am currently reading up), but I thought I would simultaneously check if the community has any ideas about how to either fix this issue, or else another way to update my code that doesn’t involve FemtoCleaner and Github.

Thanks in advance.

Colin

I am quite sure Deprecations.jl does not work with CSTParser master. I intend to upgrade it in the coming days though.

Thanks for responding. I just checked, and I get the same error message regardless of whether CSTParser is on stable or master. But I’ll keep an eye out for the upgrade and come back and try Deprecations again once it goes through.

You might have to downgrade CSTParser to the previous version.

I’ll try that and if I can get it to work I’ll post the details here.
Cheers -colin

Yep, that did it! For other users, on v0.6 I used Pkg.pin("CSTParser", v"0.2.1"), and using Deprecations now works fine.

Two quick questions:

  1. I found that the edit_file function in Deprecations doesn’t work if you input just the file-name (as a String). I think this is because the second argument to edit_file is supposed to have a default value, but currently does not. I haven’t lodged this as an issue because I’m not sure if it is actually supposed to be this way. I got around this by going to line 171 in Deprecations.jl, and pasting the default value for the second argument (deps) from the edit_markdown function immediately below, and everything seems to work fine now. If you think this is an appropriate fix, let me know and I’d be happy to open a PR on Deprecations.

  2. I noticed that the parser does not currently fix up parametric type syntax in method signatures if the method signature includes a parametric return type declaration. That is, the parser is able to update f{T}(x::T) = x to f(x::T) where {T} = x without a problem, but it is not able to update f{T}(x::T)::T = x to (f(x::T) where {T})::T = x (which I understand is the appropriate new syntax). Is this a known issue? Is there somewhere I should mention this? (or perhaps it is something I can add myself?)

Cheers, and thanks for all the help.

Colin