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

macro internal error when input ends with an escaped sequence #35

Closed
vtjnash opened this issue Feb 5, 2024 · 2 comments
Closed

macro internal error when input ends with an escaped sequence #35

vtjnash opened this issue Feb 5, 2024 · 2 comments

Comments

@vtjnash
Copy link
Member

vtjnash commented Feb 5, 2024

julia> styled"\\\n"
ERROR: LoadError: MethodError: no method matching lastindex(::Nothing)
The function `lastindex` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  lastindex(::Any, !Matched::Any)
   @ Base abstractarray.jl:427
  lastindex(!Matched::Base64.Buffer)
   @ Base64 ~/julia/usr/share/julia/stdlib/v1.11/Base64/src/buffer.jl:19
  lastindex(!Matched::LazyString)
   @ Base strings/lazy.jl:93
  ...

Stacktrace:
 [1] last(a::Nothing)
   @ Base ./abstractarray.jl:527
 [2] (::StyledStrings.var"#escaped!#44")(state::@NamedTuple{…}, i::Int64, char::Char)
   @ StyledStrings ~/julia/usr/share/julia/stdlib/v1.11/StyledStrings/src/stylemacro.jl:218
 [3] (::StyledStrings.var"#run_state_machine!#66"{…})(state::@NamedTuple{…})
   @ StyledStrings ~/julia/usr/share/julia/stdlib/v1.11/StyledStrings/src/stylemacro.jl:641
 [4] var"@styled_str"(__source__::LineNumberNode, __module__::Module, raw_content::String)
   @ StyledStrings ~/julia/usr/share/julia/stdlib/v1.11/StyledStrings/src/stylemacro.jl:669
in expression starting at REPL[8]:1
Some type information was truncated. Use `show(err)` to see complete types.
@tecosaur
Copy link
Collaborator

tecosaur commented Feb 6, 2024

Thanks! I see that escaped! is missing the !isempty(state.s) check that appears with many of the other invocations of peek(state.s).

@tecosaur
Copy link
Collaborator

Should be fixed in 26b5d2f

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