Skip to content

suboptimal inference for nextind, prevind on AnnotatedString #57606

@nsajko

Description

@nsajko

AnnotatedString is the only AbstractString subtype provided with an installation of Julia for which nextind, prevind have suboptimal inference. Script:

infer_return_type(f, S::Type) = Base.infer_return_type(f, Tuple{S, Vararg})

for S  (Base.AnnotatedString, LazyString, String, SubString, SubstitutionString)
    @show S
    for f  (nextind, prevind)
        print(' '^4)
        @show f
        print(' '^8)
        print("* ")
        @show infer_return_type(f, S)
    end
end

Output:

S = Base.AnnotatedString
    f = nextind
        * infer_return_type(f, S) = Any
    f = prevind
        * infer_return_type(f, S) = Any
S = LazyString
    f = nextind
        * infer_return_type(f, S) = Int64
    f = prevind
        * infer_return_type(f, S) = Int64
S = String
    f = nextind
        * infer_return_type(f, S) = Int64
    f = prevind
        * infer_return_type(f, S) = Int64
S = SubString
    f = nextind
        * infer_return_type(f, S) = Int64
    f = prevind
        * infer_return_type(f, S) = Int64
S = SubstitutionString
    f = nextind
        * infer_return_type(f, S) = Int64
    f = prevind
        * infer_return_type(f, S) = Int64

NB: the specific example shown above will be fixed when #57605 is fixed, however someone (maybe me, not sure) should probably look into the root cause in the AnnotatedString implementation.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions