diff --git a/README.md b/README.md index e5dcc0d4a..feb1658b8 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `IOContext` accepting key-value `Pair`s ([#23271]). +* `get` do-block syntax supported when using `ENV` ([#23412]). + ## Renaming @@ -361,6 +363,7 @@ includes this fix. Find the minimum version from there. [#23051]: https://github.com/JuliaLang/julia/issues/23051 [#23235]: https://github.com/JuliaLang/julia/issues/23235 [#23271]: https://github.com/JuliaLang/julia/issues/23271 +[#23412]: https://github.com/JuliaLang/julia/issues/23412 [#23427]: https://github.com/JuliaLang/julia/issues/23427 [#23570]: https://github.com/JuliaLang/julia/issues/23570 [#23666]: https://github.com/JuliaLang/julia/issues/23666 diff --git a/src/Compat.jl b/src/Compat.jl index 59be2a900..aaa8c3f46 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -837,6 +837,13 @@ end export Uninitialized, uninitialized end +# 0.7.0-DEV.1499 +if VERSION < v"0.7.0-DEV.1499" + function Base.get(f::Base.Callable, ::Base.EnvHash, k::AbstractString) + Base.access_env(k->f(), k) + end +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index 8538080b9..2478dbaf9 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -934,6 +934,12 @@ let A = [1] @test x == 1 end +# 0.7.0-DEV.1499 +let key = "TEST_23412" + @test !haskey(ENV, key) + @test get(() -> "default", ENV, key) == "default" +end + if VERSION < v"0.6.0" include("deprecated.jl") end