diff --git a/base/char.jl b/base/char.jl index 173c84711e551..99f46988fc75f 100644 --- a/base/char.jl +++ b/base/char.jl @@ -82,8 +82,8 @@ end struct CodePointError{T<:Integer} <: Exception code::T end -@noinline invalid_char(c::AbstractChar) = throw(InvalidCharError(c)) -@noinline code_point_err(u::Integer) = throw(CodePointError(u)) +@noinline throw_invalid_char(c::AbstractChar) = throw(InvalidCharError(c)) +@noinline throw_code_point_err(u::Integer) = throw(CodePointError(u)) function ismalformed(c::Char) u = reinterpret(UInt32, c) @@ -129,7 +129,7 @@ function UInt32(c::Char) t0 = trailing_zeros(u) & 56 (l1 == 1) | (8l1 + t0 > 32) | ((((u & 0x00c0c0c0) ⊻ 0x00808080) >> t0 != 0) | is_overlong_enc(u)) && - invalid_char(c)::Union{} + throw_invalid_char(c) u &= 0xffffffff >> l1 u >>= t0 ((u & 0x0000007f) >> 0) | ((u & 0x00007f00) >> 2) | @@ -157,7 +157,7 @@ end function Char(u::UInt32) u < 0x80 && return reinterpret(Char, u << 24) - u < 0x00200000 || code_point_err(u)::Union{} + u < 0x00200000 || throw_code_point_err(u) c = ((u << 0) & 0x0000003f) | ((u << 2) & 0x00003f00) | ((u << 4) & 0x003f0000) | ((u << 6) & 0x3f000000) c = u < 0x00000800 ? (c << 16) | 0xc0800000 : diff --git a/stdlib/LibGit2/src/LibGit2.jl b/stdlib/LibGit2/src/LibGit2.jl index 7ce6274a67589..5970ae19359bf 100644 --- a/stdlib/LibGit2/src/LibGit2.jl +++ b/stdlib/LibGit2/src/LibGit2.jl @@ -963,11 +963,15 @@ end const ENSURE_INITIALIZED_LOCK = ReentrantLock() +@noinline function throw_negative_refcount_error(x::Int) + error("Negative LibGit2 REFCOUNT $x\nThis shouldn't happen, please file a bug report!") +end + function ensure_initialized() lock(ENSURE_INITIALIZED_LOCK) do x = Threads.atomic_cas!(REFCOUNT, 0, 1) x > 0 && return - x < 0 && negative_refcount_error(x)::Union{} + x < 0 && throw_negative_refcount_error(x) try initialize() catch Threads.atomic_sub!(REFCOUNT, 1) @@ -978,10 +982,6 @@ function ensure_initialized() return nothing end -@noinline function negative_refcount_error(x::Int) - error("Negative LibGit2 REFCOUNT $x\nThis shouldn't happen, please file a bug report!") -end - @noinline function initialize() @check ccall((:git_libgit2_init, :libgit2), Cint, ()) diff --git a/test/char.jl b/test/char.jl index 325f97098b037..abc8db33cb4a7 100644 --- a/test/char.jl +++ b/test/char.jl @@ -19,7 +19,7 @@ @test widen('a') === 'a' # just check this works - @test_throws Base.CodePointError Base.code_point_err(UInt32(1)) + @test_throws Base.CodePointError Base.throw_code_point_err(UInt32(1)) end @testset "ASCII conversion to/from Integer" begin