julia
9c6c0912 - fix broken `annotate!` for `AnnotatedChar` (#60488)

Commit
4 days ago
fix broken `annotate!` for `AnnotatedChar` (#60488) The function `annotate!` has been broken for `AnnotatedChar`, at least since the inclusion StyledStrings.jl into Julia 1.11: ``` julia> using StyledStrings; annotate!(AnnotatedChar('x'), :face, :red) ERROR: FieldError: type NamedTuple has no field `value`, available fields: `label`, `val` Stacktrace: [1] macro expansion @ ./namedtuple.jl:129 [inlined] [2] @NamedTuple{label::Symbol, value}(nt::@NamedTuple{label::Symbol, val::Symbol}) @ Base ./namedtuple.jl:124 [3] annotate!(c::AnnotatedChar{Char}, label::Symbol, val::Any) @ Base ./strings/annotated.jl:370 [4] top-level scope @ REPL[1]:1 ``` This PR fixed this: ``` julia> using StyledStrings; annotate!(AnnotatedChar('x'), :face, :red) 'x': ASCII/Unicode U+0078 (category Ll: Letter, lowercase) ``` (The red color is shown in the REPL.) Side remark: Given that no-one can use this function at present, I wonder if one should reconsider the choice of arguments. Even if the annotations do not form a dictionary, I would see some benefit in writing ``` annotate!(c, label => value) ``` An extension to more than one annotation ``` annotate!(c, label1 => value1, label2 => value2) ``` would then be more natural.
Author
Parents
Loading