Skip to content

Commit 942875e

Browse files
authored
Merge pull request #2939 from zhongwencool/main
fix: crash on rebar_compiler_format:colorize/2
2 parents 9311637 + 274cf7a commit 942875e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

apps/rebar/src/rebar_compiler_format.erl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ compiler_error_format(Opts) ->
7979
colorize(Str, Col) ->
8080
Pre = string:slice(Str, 0, max(0,Col-1)),
8181
At = string:slice(Str, max(0,Col-1)),
82-
[Bad | Tail] = [B || B <- re:split(At, "([^[A-Za-z0-9_#\"]+)", []),
83-
B =/= <<>>],
84-
cf:format("~ts~!R~ts~!!~ts", [Pre,Bad,Tail]).
82+
case [B || B <- re:split(At, "([^[A-Za-z0-9_#\"]+)", []),
83+
B =/= <<>>] of
84+
[Bad |Tail] ->
85+
cf:format("~ts~!R~ts~!!~ts", [Pre,Bad,Tail]);
86+
[] ->
87+
cf:format("~ts~n", [Str])
88+
end.

0 commit comments

Comments
 (0)