Skip to content

Commit b7a1c63

Browse files
committed
Guard against assumptions that children exist
With recent JuliaSyntax changes, there are some non-trivia nodes that used to always have children that now sometimes don't. This necessitates checking that such nodes have >0 children.
1 parent c221b4e commit b7a1c63

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/JuliaSyntaxHighlighting.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function _hl_annotations!(highlights::Vector{@NamedTuple{region::UnitRange{Int},
216216
elseif nkind == K"StringMacroName"; :julia_macro
217217
elseif nkind == K"CmdMacroName"; :julia_macro
218218
elseif nkind == K"::";
219-
if JuliaSyntax.is_trivia(node)
219+
if JuliaSyntax.is_trivia(node) || numchildren(node) == 0
220220
:julia_typedec
221221
else
222222
literal_typedecl = findfirst(
@@ -256,7 +256,7 @@ function _hl_annotations!(highlights::Vector{@NamedTuple{region::UnitRange{Int},
256256
elseif (JuliaSyntax.is_keyword(nkind) ||nkind == K"->" ) && JuliaSyntax.is_trivia(node)
257257
:julia_keyword
258258
elseif nkind == K"where"
259-
if JuliaSyntax.is_trivia(node)
259+
if JuliaSyntax.is_trivia(node) || numchildren(node) == 0
260260
:julia_keyword
261261
else
262262
literal_where = findfirst(

0 commit comments

Comments
 (0)