Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Substring Overload in v1 compat #64

Closed
hexaeder opened this issue Jun 24, 2024 · 2 comments
Closed

Missing Substring Overload in v1 compat #64

hexaeder opened this issue Jun 24, 2024 · 2 comments

Comments

@hexaeder
Copy link

The following code works in Julia 1.11-beta

using StyledStrings: @styled_str
s = styled"{red:red},{green:green}"
subs = split(s, ',')[1]
lpad(subs, 10)

but errors unfortunately on v1.10 with the following error, it seems there is an overload missing.

ERROR: MethodError: no method matching SubString(::String, ::Int64, ::Int64, ::Val{:noshift})

Closest candidates are:
  SubString(::T, ::Int64, ::Int64) where T<:AbstractString
   @ Base strings/substring.jl:41
  SubString(::AbstractString, ::Integer, ::Integer)
   @ Base strings/substring.jl:42
  SubString(::SubString, ::Int64, ::Int64)
   @ Base strings/substring.jl:45
  ...

Stacktrace:
 [1] _ansi_writer(io::IOBuffer, s::SubString{…}, string_writer::typeof(write))
   @ StyledStrings ~/.julia/packages/StyledStrings/4f63t/src/io.jl:249
 [2] write(io::IOBuffer, s::SubString{StyledStrings.AnnotatedStrings.AnnotatedString{String}})
   @ StyledStrings ~/.julia/packages/StyledStrings/4f63t/src/io.jl:254
 [3] print(io::IOBuffer, s::SubString{StyledStrings.AnnotatedStrings.AnnotatedString{String}})
   @ StyledStrings ~/.julia/packages/StyledStrings/4f63t/src/io.jl:257
 [4] print_to_string(::String, ::Vararg{Any})
   @ Base ./strings/io.jl:148
 [5] string
   @ ./strings/io.jl:189 [inlined]
 [6] lpad(s::SubString{StyledStrings.AnnotatedStrings.AnnotatedString{String}}, n::Int64, p::Char)
   @ Base ./strings/util.jl:467
 [7] lpad(s::SubString{StyledStrings.AnnotatedStrings.AnnotatedString{String}}, n::Int64)
   @ Base ./strings/util.jl:462
 [8] top-level scope
   @ REPL[22]:1
 [9] top-level scope
   @ none:1
Some type information was truncated. Use `show(err)` to see complete types.
@tecosaur
Copy link
Collaborator

Ah yes, in older Julia's we have to use the (rather ugly) eval(Expr(:new, SubString.... I'll bundle this fix together with what the other fixes I've just PR'd that will need backporting.

@tecosaur
Copy link
Collaborator

Pushed in 51793a1, coming to a release soon near you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants