Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `==(::Period, ::Period)` and `isless(::Period, ::Period)` is supported for 0.5 and below. Earlier versions of Julia only supported limited comparison methods between Periods which did not support comparing custom Period subtypes. ([#21378])

* `@__MODULE__` is aliased to `current_module()` for Julia versions 0.6 and below. Versions of `Base.binding_module`, `expand`, `macroexpand`, and `include_string` were added that accept a module as the first argument. ([#22064])

## Renamed functions

* `pointer_to_array` and `pointer_to_string` have been replaced with `unsafe_wrap(Array, ...)` and `unsafe_wrap(String, ...)` respectively
Expand Down Expand Up @@ -377,3 +379,4 @@ includes this fix. Find the minimum version from there.
[#20500]: https://github.com/JuliaLang/julia/issues/20500
[#21257]: https://github.com/JuliaLang/julia/issues/21257
[#21346]: https://github.com/JuliaLang/julia/issues/21346
[#22064]: https://github.com/JuliaLang/julia/issues/22064
14 changes: 14 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,20 @@ else
using Base: StringVector
end

# https://github.com/JuliaLang/julia/pull/22064
if !isdefined(Base, Symbol("@__MODULE__"))
export @__MODULE__
macro __MODULE__()
return current_module()
end
Base.expand(mod::Module, x::ANY) = eval(mod, :(expand($(QuoteNode(x)))))
Base.macroexpand(mod::Module, x::ANY) = eval(mod, :(macroexpand($(QuoteNode(x)))))
Base.include_string(mod::Module, code::String, fname::String) =
eval(mod, :(include_string($code, $fname)))
Base.include_string(mod::Module, code::AbstractString, fname::AbstractString="string") =
eval(mod, :(include_string($code, $fname)))
end

# https://github.com/JuliaLang/julia/pull/19784
if isdefined(Base, :invokelatest)
import Base.invokelatest
Expand Down
7 changes: 5 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ A = view(rand(5,5), 1:3, 1:3)
# julia#17623
if VERSION >= v"0.5.0-dev+5509"
# Use include_string to work around unsupported syntax on Julia 0.4
include_string("""
include_string(Main, """
@test [true, false] .& [true, true] == [true, false]
@test [true, false] .| [true, true] == [true, true]
""")
Expand Down Expand Up @@ -1852,6 +1852,8 @@ if VERSION >= v"0.5.0-rc1+46"
@test b == [1,2,3]
end

@test (@__MODULE__) === Main

# invokelatest
issue19774(x) = 1
let foo() = begin
Expand All @@ -1860,7 +1862,8 @@ let foo() = begin
end
@test foo() == 2
end
@test Compat.invokelatest(current_module) === current_module()
cm359() = @__MODULE__
@test Compat.invokelatest(cm359) === @__MODULE__
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a === current_module() here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will emit a depwarn on 0.7. But perhaps worth it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just while testing yeah? Anyway, I doubt it will ever make a difference, and if you, stevengj and vtjnash are happy, I think we're probably pretty ok 😄


# PR 21378
let
Expand Down