diff --git a/base/asyncmap.jl b/base/asyncmap.jl index 6b66799f06dbb..b6b142e4e0943 100644 --- a/base/asyncmap.jl +++ b/base/asyncmap.jl @@ -23,11 +23,11 @@ then be a function that must accept a `Vector` of argument tuples and must return a vector of results. The input vector will have a length of `batch_size` or less. The following examples highlight execution in different tasks by returning -the `object_id` of the tasks in which the mapping function is executed. +the `objectid` of the tasks in which the mapping function is executed. First, with `ntasks` undefined, each element is processed in a different task. ``` -julia> tskoid() = object_id(current_task()); +julia> tskoid() = objectid(current_task()); julia> asyncmap(x->tskoid(), 1:5) 5-element Array{UInt64,1}: diff --git a/base/deprecated.jl b/base/deprecated.jl index a8f3b0fe113c4..b7ac204a9bdb9 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1563,6 +1563,13 @@ end @deprecate findn(x::AbstractMatrix) (I = findall(!iszero, x); (getindex.(I, 1), getindex.(I, 2))) @deprecate findn(x::AbstractArray{T, N}) where {T, N} (I = findall(!iszero, x); ntuple(i -> getindex.(I, i), N)) +@deprecate catch_stacktrace(c_funcs::Bool) stacktrace(catch_backtrace(), c_funcs) +@deprecate catch_stacktrace() stacktrace(catch_backtrace()) + +@deprecate method_exists hasmethod + +@deprecate object_id objectid + # issue #9053 if Sys.iswindows() function Filesystem.tempname(uunique::UInt32) diff --git a/base/exports.jl b/base/exports.jl index 70c41620243c5..9894fdff2a37f 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -692,7 +692,7 @@ export isimmutable, isless, ifelse, - object_id, + objectid, sizeof, # tasks and conditions @@ -745,7 +745,6 @@ export StackTrace, StackFrame, stacktrace, - catch_stacktrace, # types convert, @@ -789,7 +788,7 @@ export isconst, isinteractive, less, - method_exists, + hasmethod, methods, methodswith, module_name, diff --git a/base/hashing.jl b/base/hashing.jl index eb37bf0ba1157..b58bd6bbd4dec 100644 --- a/base/hashing.jl +++ b/base/hashing.jl @@ -20,7 +20,7 @@ hash(w::WeakRef, h::UInt) = hash(w.value, h) ## hashing general objects ## -hash(@nospecialize(x), h::UInt) = hash_uint(3h - object_id(x)) +hash(@nospecialize(x), h::UInt) = hash_uint(3h - objectid(x)) ## core data hashing functions ## diff --git a/base/irrationals.jl b/base/irrationals.jl index 5b863b8467cb1..2d9795b438b6b 100644 --- a/base/irrationals.jl +++ b/base/irrationals.jl @@ -114,7 +114,7 @@ isinteger(::AbstractIrrational) = false iszero(::AbstractIrrational) = false isone(::AbstractIrrational) = false -hash(x::Irrational, h::UInt) = 3*object_id(x) - h +hash(x::Irrational, h::UInt) = 3*objectid(x) - h widen(::Type{T}) where {T<:Irrational} = T diff --git a/base/multimedia.jl b/base/multimedia.jl index e26a7f854bcda..ef6abf15ae369 100644 --- a/base/multimedia.jl +++ b/base/multimedia.jl @@ -42,7 +42,7 @@ false ``` """ mimewritable(::MIME{mime}, x) where {mime} = - method_exists(show, Tuple{IO, MIME{mime}, typeof(x)}) + hasmethod(show, Tuple{IO, MIME{mime}, typeof(x)}) """ show(io, mime, x) @@ -313,7 +313,7 @@ function display(m::MIME, x) end displayable(d::D, ::MIME{mime}) where {D<:AbstractDisplay,mime} = - method_exists(display, Tuple{D,MIME{mime},Any}) + hasmethod(display, Tuple{D,MIME{mime},Any}) function displayable(m::MIME) for d in displays diff --git a/base/namedtuple.jl b/base/namedtuple.jl index f83fb98a60940..6668463dcd921 100644 --- a/base/namedtuple.jl +++ b/base/namedtuple.jl @@ -101,7 +101,7 @@ isequal(a::NamedTuple, b::NamedTuple) = false _nt_names(::NamedTuple{names}) where {names} = names _nt_names(::Type{T}) where {names,T<:NamedTuple{names}} = names -hash(x::NamedTuple, h::UInt) = xor(object_id(_nt_names(x)), hash(Tuple(x), h)) +hash(x::NamedTuple, h::UInt) = xor(objectid(_nt_names(x)), hash(Tuple(x), h)) isless(a::NamedTuple{n}, b::NamedTuple{n}) where {n} = isless(Tuple(a), Tuple(b)) # TODO: case where one argument's names are a prefix of the other's diff --git a/base/reflection.jl b/base/reflection.jl index 53409d71f8d4c..5bbb4a3582c49 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -216,11 +216,11 @@ macro isdefined(s::Symbol) end """ - object_id(x) + objectid(x) -Get a hash value for `x` based on object identity. `object_id(x)==object_id(y)` if `x === y`. +Get a hash value for `x` based on object identity. `objectid(x)==objectid(y)` if `x === y`. """ -object_id(@nospecialize(x)) = ccall(:jl_object_id, UInt, (Any,), x) +objectid(@nospecialize(x)) = ccall(:jl_object_id, UInt, (Any,), x) struct DataTypeLayout nfields::UInt32 @@ -1004,18 +1004,18 @@ function function_module(@nospecialize(f), @nospecialize(types)) end """ - method_exists(f, Tuple type, world=typemax(UInt)) -> Bool + hasmethod(f, Tuple type, world=typemax(UInt)) -> Bool Determine whether the given generic function has a method matching the given `Tuple` of argument types with the upper bound of world age given by `world`. # Examples ```jldoctest -julia> method_exists(length, Tuple{Array}) +julia> hasmethod(length, Tuple{Array}) true ``` """ -function method_exists(@nospecialize(f), @nospecialize(t), world=typemax(UInt)) +function hasmethod(@nospecialize(f), @nospecialize(t), world=typemax(UInt)) t = to_tuple_type(t) t = signature_type(f, t) return ccall(:jl_method_exists, Cint, (Any, Any, UInt), typeof(f).name.mt, t, world) != 0 diff --git a/base/replutil.jl b/base/replutil.jl index cf04656d733b6..a8446363c4cd3 100644 --- a/base/replutil.jl +++ b/base/replutil.jl @@ -386,13 +386,13 @@ function showerror(io::IO, ex::MethodError) # Check for local functions that shadow methods in Base if f_is_function && isdefined(Base, name) basef = getfield(Base, name) - if basef !== ex.f && method_exists(basef, arg_types) + if basef !== ex.f && hasmethod(basef, arg_types) println(io) print(io, "You may have intended to import Base.", name) end end - if (ex.world != typemax(UInt) && method_exists(ex.f, arg_types) && - !method_exists(ex.f, arg_types, ex.world)) + if (ex.world != typemax(UInt) && hasmethod(ex.f, arg_types) && + !hasmethod(ex.f, arg_types, ex.world)) curworld = ccall(:jl_get_world_counter, UInt, ()) println(io) print(io, "The applicable method may be too new: running in world age $(ex.world), while current world is $(curworld).") diff --git a/base/stacktraces.jl b/base/stacktraces.jl index 7707aa31af903..587801630f6e3 100644 --- a/base/stacktraces.jl +++ b/base/stacktraces.jl @@ -11,7 +11,7 @@ import Base.Serializer: serialize, deserialize using Base.Printf: @printf using Base: coalesce -export StackTrace, StackFrame, stacktrace, catch_stacktrace +export StackTrace, StackFrame, stacktrace """ StackFrame @@ -71,7 +71,7 @@ StackFrame(func, file, line) = StackFrame(Symbol(func), Symbol(file), line, StackTrace An alias for `Vector{StackFrame}` provided for convenience; returned by calls to -`stacktrace` and `catch_stacktrace`. +`stacktrace`. """ const StackTrace = Vector{StackFrame} @@ -261,14 +261,6 @@ end stacktrace(c_funcs::Bool=false) = stacktrace(backtrace(), c_funcs) -""" - catch_stacktrace([c_funcs::Bool=false]) -> StackTrace - -Returns the stack trace for the most recent error thrown, rather than the current execution -context. -""" -catch_stacktrace(c_funcs::Bool=false) = stacktrace(catch_backtrace(), c_funcs) - """ remove_frames!(stack::StackTrace, name::Symbol) diff --git a/doc/src/base/base.md b/doc/src/base/base.md index a0db28af61764..7a94e593a5d14 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -111,7 +111,7 @@ Core.typeassert Core.typeof Core.tuple Base.ntuple -Base.object_id +Base.objectid Base.hash Base.finalizer Base.finalize @@ -176,7 +176,7 @@ Base.Enums.@enum ```@docs Core.Function -Base.method_exists +Base.hasmethod Core.applicable Core.invoke Base.invokelatest diff --git a/doc/src/base/stacktraces.md b/doc/src/base/stacktraces.md index aa2ae7bab2b02..3286ee204dc74 100644 --- a/doc/src/base/stacktraces.md +++ b/doc/src/base/stacktraces.md @@ -4,7 +4,6 @@ Base.StackTraces.StackFrame Base.StackTraces.StackTrace Base.StackTraces.stacktrace -Base.StackTraces.catch_stacktrace ``` The following methods and types in `Base.StackTraces` are not exported and need to be called e.g. diff --git a/doc/src/manual/metaprogramming.md b/doc/src/manual/metaprogramming.md index b607bfbcd2ed4..2ac0c0c829e8e 100644 --- a/doc/src/manual/metaprogramming.md +++ b/doc/src/manual/metaprogramming.md @@ -1073,7 +1073,7 @@ When defining generated functions, there are four main differences to ordinary f 3. Instead of calculating something or performing some action, you return a *quoted expression* which, when evaluated, does what you want. 4. Generated functions must not *mutate* or *observe* any non-constant global state (including, - for example, IO, locks, non-local dictionaries, or using `method_exists`). + for example, IO, locks, non-local dictionaries, or using `hasmethod`). This means they can only read global constants, and cannot have any side effects. In other words, they must be completely pure. Due to an implementation limitation, this also means that they currently cannot define a closure diff --git a/doc/src/manual/modules.md b/doc/src/manual/modules.md index 56635997123e9..bb7c0f28e2b4f 100644 --- a/doc/src/manual/modules.md +++ b/doc/src/manual/modules.md @@ -299,7 +299,7 @@ are a trickier case. In the common case where the keys are numbers, strings, sy `Expr`, or compositions of these types (via arrays, tuples, sets, pairs, etc.) they are safe to precompile. However, for a few other key types, such as `Function` or `DataType` and generic user-defined types where you haven't defined a `hash` method, the fallback `hash` method depends -on the memory address of the object (via its `object_id`) and hence may change from run to run. +on the memory address of the object (via its `objectid`) and hence may change from run to run. If you have one of these key types, or if you aren't sure, to be safe you can initialize this dictionary from within your `__init__` function. Alternatively, you can use the `IdDict` dictionary type, which is specially handled by precompilation so that it is safe to initialize @@ -328,7 +328,7 @@ Other known potential failure scenarios include: at the end of compilation. All subsequent usages of this incrementally compiled module will start from that same counter value. - Note that `object_id` (which works by hashing the memory pointer) has similar issues (see notes + Note that `objectid` (which works by hashing the memory pointer) has similar issues (see notes on `Dict` usage below). One alternative is to use a macro to capture [`@__MODULE__`](@ref) and store it alone with the current `counter` value, diff --git a/doc/src/manual/stacktraces.md b/doc/src/manual/stacktraces.md index 5b7a5714e91db..56d21d9b3b17d 100644 --- a/doc/src/manual/stacktraces.md +++ b/doc/src/manual/stacktraces.md @@ -131,8 +131,8 @@ frame is missing entirely. This is understandable, given that [`stacktrace`](@re from the context of the *catch*. While in this example it's fairly easy to find the actual source of the error, in complex cases tracking down the source of the error becomes nontrivial. -This can be remedied by calling [`catch_stacktrace`](@ref) instead of [`stacktrace`](@ref). -Instead of returning callstack information for the current context, [`catch_stacktrace`](@ref) +This can be remedied by passing the result of [`catch_backtrace`](@ref) to [`stacktrace`](@ref). +Instead of returning callstack information for the current context, [`catch_backtrace`](@ref) returns stack information for the context of the most recent exception: ```julia-repl @@ -142,7 +142,7 @@ bad_function (generic function with 1 method) julia> @noinline example() = try bad_function() catch - catch_stacktrace() + stacktrace(catch_backtrace()) end example (generic function with 1 method) @@ -167,7 +167,7 @@ julia> @noinline function grandparent() parent() catch err println("ERROR: ", err.msg) - catch_stacktrace() + stacktrace(catch_backtrace()) end end grandparent (generic function with 1 method) diff --git a/examples/staged.jl b/examples/staged.jl index 5b14f1d1117d3..96f3ebb6aa6c6 100644 --- a/examples/staged.jl +++ b/examples/staged.jl @@ -32,7 +32,7 @@ macro staged(fdef) ($gengf)() = 0 # should be initially empty GF function ($fname)($(argspec...)) ($argtypes) = typeof(tuple($(argnames...))) - if !method_exists($gengf, $argtypes) + if !hasmethod($gengf, $argtypes) ($genbody) = apply(($expander), ($argtypes)) add_method($gengf, Any[$(qargnames...)], $argtypes, $genbody) diff --git a/stdlib/Distributed/src/clusterserialize.jl b/stdlib/Distributed/src/clusterserialize.jl index b5412b59f5807..7af4485c29bad 100644 --- a/stdlib/Distributed/src/clusterserialize.jl +++ b/stdlib/Distributed/src/clusterserialize.jl @@ -14,7 +14,7 @@ mutable struct ClusterSerializer{I<:IO} <: AbstractSerializer pid::Int # Worker we are connected to. tn_obj_sent::Set{UInt64} # TypeName objects sent - glbs_sent::Dict{UInt64, UInt64} # (key,value) -> (object_id, hash_value) + glbs_sent::Dict{UInt64, UInt64} # (key,value) -> (objectid, hash_value) glbs_in_tnobj::Dict{UInt64, Vector{Symbol}} # Track globals referenced in # anonymous functions. anonfunc_id::UInt64 @@ -116,7 +116,7 @@ function serialize(s::ClusterSerializer, g::GlobalRef) end # Send/resend a global object if -# a) has not been sent previously, i.e., we are seeing this object_id for the first time, or, +# a) has not been sent previously, i.e., we are seeing this objectid for the first time, or, # b) hash value has changed or # c) is a bits type function syms_2b_sent(s::ClusterSerializer, identifier) @@ -128,7 +128,7 @@ function syms_2b_sent(s::ClusterSerializer, identifier) if isbits(v) push!(lst, sym) else - oid = object_id(v) + oid = objectid(v) if haskey(s.glbs_sent, oid) # We have sent this object before, see if it has changed. s.glbs_sent[oid] != hash(sym, hash(v)) && push!(lst, sym) @@ -143,7 +143,7 @@ end function serialize_global_from_main(s::ClusterSerializer, sym) v = getfield(Main, sym) - oid = object_id(v) + oid = objectid(v) record_v = true if isbits(v) record_v = false @@ -179,7 +179,7 @@ function deserialize_global_from_main(s::ClusterSerializer, sym) end function delete_global_tracker(s::ClusterSerializer, v) - oid = object_id(v) + oid = objectid(v) if haskey(s.glbs_sent, oid) delete!(s.glbs_sent, oid) end diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index d9536e559f600..9eb6d9cd5a547 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -1161,8 +1161,8 @@ v6 = FooModEverywhere Base.Serializer.serialize_type(s, TestSerCnt) serialize(s, t.v) global testsercnt_d - cnt = get!(testsercnt_d, object_id(t), 0) - testsercnt_d[object_id(t)] = cnt+1 + cnt = get!(testsercnt_d, objectid(t), 0) + testsercnt_d[objectid(t)] = cnt+1 end Base.deserialize(s::AbstractSerializer, ::Type{TestSerCnt}) = TestSerCnt(deserialize(s)) @@ -1174,22 +1174,22 @@ for i in 1:5 remotecall_fetch(()->tsc, id_other) end # should have been serialized only once -@test testsercnt_d[object_id(tsc)] == 1 +@test testsercnt_d[objectid(tsc)] == 1 # hash values are changed n=5 -testsercnt_d[object_id(tsc)] = 0 +testsercnt_d[objectid(tsc)] = 0 for i in 1:n tsc.v[i] = i remotecall_fetch(()->tsc, id_other) end # should have been serialized as many times as the loop -@test testsercnt_d[object_id(tsc)] == n +@test testsercnt_d[objectid(tsc)] == n # Multiple references in a closure should be serialized only once. global mrefs = TestSerCnt(fill(1.,10)) @test remotecall_fetch(()->(mrefs.v, 2*mrefs.v, 3*mrefs.v), id_other) == (fill(1.,10), fill(2.,10), fill(3.,10)) -@test testsercnt_d[object_id(mrefs)] == 1 +@test testsercnt_d[objectid(mrefs)] == 1 # nested anon functions @@ -1239,9 +1239,9 @@ global ids_func = ()->ids_cleanup clust_ser = (Distributed.worker_from_id(id_other)).w_serializer @test remotecall_fetch(ids_func, id_other) == ids_cleanup -@test haskey(clust_ser.glbs_sent, object_id(ids_cleanup)) +@test haskey(clust_ser.glbs_sent, objectid(ids_cleanup)) finalize(ids_cleanup) -@test !haskey(clust_ser.glbs_sent, object_id(ids_cleanup)) +@test !haskey(clust_ser.glbs_sent, objectid(ids_cleanup)) # TODO Add test for cleanup from `clust_ser.glbs_in_tnobj` diff --git a/stdlib/SharedArrays/test/runtests.jl b/stdlib/SharedArrays/test/runtests.jl index 7441683b146d6..6dcea0aaa3b73 100644 --- a/stdlib/SharedArrays/test/runtests.jl +++ b/stdlib/SharedArrays/test/runtests.jl @@ -284,7 +284,7 @@ finalize(d) let aorig = a1 = SharedArray{Float64}((3, 3)) a1 = remotecall_fetch(fill!, id_other, a1, 1.0) - @test object_id(aorig) == object_id(a1) + @test objectid(aorig) == objectid(a1) id = a1.id aorig = nothing a1 = remotecall_fetch(fill!, id_other, a1, 1.0) diff --git a/test/asyncmap.jl b/test/asyncmap.jl index 1a23290679f2b..be180ba237e52 100644 --- a/test/asyncmap.jl +++ b/test/asyncmap.jl @@ -3,13 +3,13 @@ using Random # Test asyncmap -@test allunique(asyncmap(x->(sleep(1.0);object_id(current_task())), 1:10)) +@test allunique(asyncmap(x->(sleep(1.0);objectid(current_task())), 1:10)) # num tasks -@test length(unique(asyncmap(x->(yield();object_id(current_task())), 1:20; ntasks=5))) == 5 +@test length(unique(asyncmap(x->(yield();objectid(current_task())), 1:20; ntasks=5))) == 5 # default num tasks -@test length(unique(asyncmap(x->(yield();object_id(current_task())), 1:200))) == 100 +@test length(unique(asyncmap(x->(yield();objectid(current_task())), 1:200))) == 100 # ntasks as a function let nt=0 @@ -18,7 +18,7 @@ let nt=0 # nt_func() will be called initally once and then for every # iteration end -@test length(unique(asyncmap(x->(yield();object_id(current_task())), 1:200; ntasks=nt_func))) == 7 +@test length(unique(asyncmap(x->(yield();objectid(current_task())), 1:200; ntasks=nt_func))) == 7 # batch mode tests let ctr=0 diff --git a/test/core.jl b/test/core.jl index 6ec2878a78a5f..b6040eb90ea4e 100644 --- a/test/core.jl +++ b/test/core.jl @@ -3478,7 +3478,7 @@ const const_array_int2 = Array{Int} test_eq_array_int() = ===(const_array_int1, const_array_int2) @test test_eq_array_int() -# object_id of haspadding field +# objectid of haspadding field struct HasPadding x::Bool y::Int @@ -3490,7 +3490,7 @@ let hashaspadding = Ref(HasHasPadding(HasPadding(true,1))), hashaspadding2 = Ref(HasHasPadding(HasPadding(true,1))) unsafe_store!(convert(Ptr{UInt8},pointer_from_objref(hashaspadding)), 0x12, 2) unsafe_store!(convert(Ptr{UInt8},pointer_from_objref(hashaspadding2)), 0x21, 2) - @test object_id(hashaspadding[]) == object_id(hashaspadding2[]) + @test objectid(hashaspadding[]) == objectid(hashaspadding2[]) end # issue #12517 @@ -3801,7 +3801,7 @@ let end # issue #14564 -@test isa(object_id(Tuple.name.cache), Integer) +@test isa(objectid(Tuple.name.cache), Integer) # issue #14691 mutable struct T14691; a::UInt; end @@ -3860,7 +3860,7 @@ end # issue #14610 let sometypes = (Int,Int8) f(::Union{ntuple(i->Type{sometypes[i]}, length(sometypes))...}) = 1 - @test method_exists(f, (Union{Type{Int},Type{Int8}},)) + @test hasmethod(f, (Union{Type{Int},Type{Int8}},)) end let @@ -5637,7 +5637,7 @@ let x5 = UnionField5(nothing, Int8(3)) @test x5 == x5 @test x5 === x5copy @test x5 == x5copy - @test object_id(x5) === object_id(x5copy) + @test objectid(x5) === objectid(x5copy) @test hash(x5) === hash(x5copy) end @@ -5668,7 +5668,7 @@ let @test b === b2 === b3 @test compare(b, b2) @test compare(b, b3) - @test object_id(b) === object_id(b2) == object_id(b3) + @test objectid(b) === objectid(b2) == objectid(b3) @test b.x === Int8(91) @test b.z === Int8(23) @test b.y === A23367((Int8(1), Int8(2), Int8(3), Int8(4), Int8(5), Int8(6), Int8(7))) diff --git a/test/hashing.jl b/test/hashing.jl index 4b210c1e3537b..ba97016f16a88 100644 --- a/test/hashing.jl +++ b/test/hashing.jl @@ -207,7 +207,7 @@ end # issue #20744 @test hash(:c, hash(:b, hash(:a))) != hash(:a, hash(:b, hash(:c))) -# issue #5849, object_id of types +# issue #5849, objectid of types @test Vector === (Array{T,1} where T) @test (Pair{A,B} where A where B) !== (Pair{A,B} where B where A) let vals_expr = :(Any[Vector, (Array{T,1} where T), 1, 2, Union{Int, String}, Union{String, Int}, @@ -219,6 +219,6 @@ let vals_expr = :(Any[Vector, (Array{T,1} where T), 1, 2, Union{Int, String}, Un vals_b = eval(vals_expr) for (i, a) in enumerate(vals_a), (j, b) in enumerate(vals_b) @test i != j || (a === b) - @test (a === b) == (object_id(a) == object_id(b)) + @test (a === b) == (objectid(a) == objectid(b)) end end diff --git a/test/replutil.jl b/test/replutil.jl index 8602ac55ad356..91abb3c1d61dc 100644 --- a/test/replutil.jl +++ b/test/replutil.jl @@ -170,7 +170,7 @@ macro except_stackframe(expr, err_type) try $(esc(expr)) catch err - st = catch_stacktrace() + st = stacktrace(catch_backtrace()) end err === nothing && error("expected failure, but no exception thrown") @test typeof(err) === $(esc(err_type)) diff --git a/test/stacktraces.jl b/test/stacktraces.jl index ea646649203b7..ca51dec749860 100644 --- a/test/stacktraces.jl +++ b/test/stacktraces.jl @@ -65,7 +65,7 @@ let ct = current_task() try bad_function() catch - return catch_stacktrace() + return stacktrace(catch_backtrace()) end end line_numbers = @__LINE__() .- [15, 10, 5] @@ -73,7 +73,7 @@ let ct = current_task() # Test try...catch with stacktrace @test try_stacktrace()[1] == StackFrame(:try_stacktrace, @__FILE__, line_numbers[2]) - # Test try...catch with catch_stacktrace + # Test try...catch with catch_backtrace @test try_catch()[1:2] == [ StackFrame(:bad_function, @__FILE__, line_numbers[1]), StackFrame(:try_catch, @__FILE__, line_numbers[3]) @@ -85,7 +85,7 @@ using Test @inline g(x) = (y = throw("a"); y) # the inliner does not insert the proper markers when inlining a single expression @inline h(x) = (y = g(x); y) # this test could be extended to check for that if we switch to linear representation f(x) = (y = h(x); y) -trace = (try; f(3); catch; catch_stacktrace(); end)[1:3] +trace = (try; f(3); catch; stacktrace(catch_backtrace()); end)[1:3] can_inline = Bool(Base.JLOptions().can_inline) for (frame, func, inlined) in zip(trace, [g,h,f], (can_inline, can_inline, false)) @test frame.func === typeof(func).name.mt.name diff --git a/test/strings/basic.jl b/test/strings/basic.jl index 29ea38b3664f2..04db3d9a49233 100644 --- a/test/strings/basic.jl +++ b/test/strings/basic.jl @@ -18,7 +18,7 @@ using Random @test codegen_egal_of_strings(string("ab", 'c'), "abc") === (true, false) let strs = ["", "a", "a b c", "до свидания"] for x in strs, y in strs - @test (x === y) == (object_id(x) == object_id(y)) + @test (x === y) == (objectid(x) == objectid(y)) end end end diff --git a/test/syntax.jl b/test/syntax.jl index 4791be7af4e0e..2e5e3c3ab43ca 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -795,7 +795,7 @@ module Mod18756 mutable struct Type end end -@test method_exists(Mod18756.Type, ()) +@test hasmethod(Mod18756.Type, ()) # issue 18002 @test Meta.parse("Foo{T} = Bar{T}") == Expr(:(=), Expr(:curly, :Foo, :T), Expr(:curly, :Bar, :T))