diff --git a/base/strings/unicode.jl b/base/strings/unicode.jl index b659ec080680b..9a44912946205 100644 --- a/base/strings/unicode.jl +++ b/base/strings/unicode.jl @@ -350,7 +350,7 @@ function category_code(c::AbstractChar) end function category_code(x::Integer) - x ≤ 0x10ffff ? ccall(:utf8proc_category, Cint, (UInt32,), x) : Cint(30) + x ≤ 0x10ffff ? (@assume_effects :foldable @ccall utf8proc_category(UInt32(x)::UInt32)::Cint) : Cint(30) end # more human-readable representations of the category code diff --git a/test/char.jl b/test/char.jl index 5a522dfd1c743..5da92121b1630 100644 --- a/test/char.jl +++ b/test/char.jl @@ -361,12 +361,17 @@ end @test convert(ASCIIChar, 1) == Char(1) end -@testset "foldable isuppercase/islowercase" begin +@testset "foldable functions" begin v = @inferred (() -> Val(isuppercase('C')))() @test v isa Val{true} v = @inferred (() -> Val(islowercase('C')))() @test v isa Val{false} + v = @inferred (() -> Val(isletter('C')))() + @test v isa Val{true} + v = @inferred (() -> Val(isnumeric('C')))() + @test v isa Val{false} + struct MyChar <: AbstractChar x :: Char end @@ -377,4 +382,9 @@ end @test v isa Val{true} v = @inferred (() -> Val(islowercase(MyChar('C'))))() @test v isa Val{false} + + v = @inferred (() -> Val(isletter(MyChar('C'))))() + @test v isa Val{true} + v = @inferred (() -> Val(isnumeric(MyChar('C'))))() + @test v isa Val{false} end