diff --git a/src/Compat.jl b/src/Compat.jl index d22d3613f9145..1956a2683fb15 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -357,6 +357,26 @@ function rewrite_pairs_to_tuples!(expr::Expr) return expr end +# rewrites accesses to IOContext dicts +function rewrite_iocontext!(expr::Expr) + if expr.head == :call && expr.args[1] == :get + key = expr.args[3] + if (((isa(key, QuoteNode) && key.value == :limit) || + (isa(key, Expr) && key.head == :quote && key.args[1] == :limit)) + && expr.args[4] == false) + if VERSION >= v"0.5.0-dev+1936" && VERSION < v"0.5.0-dev+4305" + expr.args[1] = :(Base.limit_output) + deleteat!(expr.args, 3:4) + elseif VERSION < v"0.5.0-dev+1936" + expr.head = :quote + expr.args[1] = false + deleteat!(expr.args, 3:4) + end + end + end + expr +end + if VERSION < v"0.4.0-dev+707" macro inline(ex) esc(ex) @@ -515,6 +535,9 @@ function _compat(ex::Expr) elseif VERSION < v"0.4.0-dev+1246" && f == :String ex = Expr(:call, :bytestring, ex.args[2:end]...) end + if VERSION < v"0.5.0-dev+4305" + rewrite_iocontext!(ex) + end elseif ex.head === :curly f = ex.args[1] if VERSION < v"0.4.0-dev+4319" && f === :Tuple diff --git a/test/runtests.jl b/test/runtests.jl index 437a1cda42f25..d2960c8582d9c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1183,3 +1183,6 @@ if VERSION < v"0.5.0-dev+4267" else @test Compat.KERNEL == Sys.KERNEL end + +io = IOBuffer() +@test @compat(get(io, :limit, false)) == false