Skip to content

Commit 24f7349

Browse files
committed
Fix compiler warnings
1 parent a5d96e2 commit 24f7349

File tree

2 files changed

+7
-64
lines changed

2 files changed

+7
-64
lines changed

apps/markdown/src/mdast/markdown_mdast_compile_context.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ Context used to compile markdown.
5555
]).
5656

5757
%% Types
58-
-type node() :: markdown_mdast_node:t().
58+
-type mdast_node() :: markdown_mdast_node:t().
5959
-type node_mut_func() :: node_mut_func(dynamic(), dynamic()).
60-
-type node_mut_func(AccIn, AccOut) :: fun((Node :: node(), AccIn) -> {NewNode :: node(), AccOut}).
60+
-type node_mut_func(AccIn, AccOut) :: fun((Node :: mdast_node(), AccIn) -> {NewNode :: mdast_node(), AccOut}).
6161
-type t() :: #markdown_mdast_compile_context{}.
6262

6363
-export_type([
64-
node/0,
64+
mdast_node/0,
6565
node_mut_func/0,
6666
node_mut_func/2,
6767
t/0

apps/markdown_test/src/markdown_test_utils_swc.erl

Lines changed: 4 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ parse_esm(Value) ->
5555
parse_expression(Value, Kind) ->
5656
parse_expression_impl(Value, Kind).
5757

58+
%% @private
59+
-spec parse_expression_impl(Value, Kind) -> Signal when
60+
Value :: unicode:unicode_binary(), Kind :: markdown_mdx:expression_kind(), Signal :: markdown_mdx:signal().
5861
parse_expression_impl(Value, attribute_expression) ->
5962
% For attribute expressions like <a {...b}>, we need to validate:
6063
% 1. Must be a spread (start with ...)
@@ -503,7 +506,7 @@ find_matching_brace(<<>>, Offset, _Depth) ->
503506
{found, Offset + 1};
504507
find_matching_brace(<<"{", Rest/binary>>, Offset, Depth) ->
505508
find_matching_brace(Rest, Offset + 1, Depth + 1);
506-
find_matching_brace(<<"}", Rest/binary>>, Offset, 1) ->
509+
find_matching_brace(<<"}", _Rest/binary>>, Offset, 1) ->
507510
% Found the matching closing brace - return offset + 1 to point after it
508511
{found, Offset + 1};
509512
find_matching_brace(<<"}", Rest/binary>>, Offset, Depth) ->
@@ -587,52 +590,6 @@ case_not_empty_spread(Trimmed, Value, ValueLen) ->
587590
end
588591
end.
589592

590-
%% Old version kept for reference
591-
case_not_empty_spread_old(Trimmed, Value, ValueLen) ->
592-
% Check if effectively empty (empty, whitespace, or very short)
593-
TrimmedLen = byte_size(Trimmed),
594-
IsEffectivelyEmpty =
595-
TrimmedLen =:= 0 orelse
596-
(ValueLen < 2 andalso TrimmedLen =:= 0) orelse
597-
(ValueLen =:= 0),
598-
599-
case IsEffectivelyEmpty of
600-
true ->
601-
% Empty expression - offset should be 4 to point after {}
602-
{error, <<"Unexpected prop in spread (such as `{x}`): only a spread is supported (such as `{...x}`)">>, 4};
603-
false ->
604-
case Trimmed of
605-
<<"...", Rest/binary>> ->
606-
% It's a spread, validate the rest
607-
validate_spread(Rest, ValueLen);
608-
_ ->
609-
% Check if value is all whitespace (another way to detect empty)
610-
AllWhitespace = is_all_whitespace(Value),
611-
case AllWhitespace of
612-
true ->
613-
% Treat as empty
614-
{error,
615-
<<"Unexpected prop in spread (such as `{x}`): only a spread is supported (such as `{...x}`)">>,
616-
4};
617-
false ->
618-
% Not a spread - determine if it's a simple assignment
619-
IsCleanAssignment = is_clean_assignment(Trimmed, Value),
620-
case IsCleanAssignment of
621-
true ->
622-
% Simple assignment like "b=c"
623-
{error,
624-
<<"Could not parse expression with swc: assignment property is invalid syntax">>,
625-
7};
626-
false ->
627-
% Not a spread - offset at start
628-
{error,
629-
<<"Unexpected prop in spread (such as `{x}`): only a spread is supported (such as `{...x}`)">>,
630-
0}
631-
end
632-
end
633-
end
634-
end.
635-
636593
%% @private
637594
-spec is_all_whitespace(Value) -> boolean() when
638595
Value :: unicode:unicode_binary().
@@ -675,20 +632,6 @@ is_clean_assignment(Trimmed, Original) ->
675632
end
676633
end.
677634

678-
%% @private
679-
-spec is_simple_assignment(Value) -> boolean() when
680-
Value :: unicode:unicode_binary().
681-
is_simple_assignment(Value) ->
682-
% Check if this is a simple assignment pattern: identifier = value
683-
% Must have = but no braces
684-
case {binary:match(Value, <<"=">>), binary:match(Value, <<"{">>), binary:match(Value, <<"}">>)} of
685-
{{_, _}, nomatch, nomatch} ->
686-
% Has equals but no braces - it's a simple assignment
687-
true;
688-
_ ->
689-
false
690-
end.
691-
692635
%% @private
693636
-spec validate_spread(Rest, ValueLen) -> ok | {error, Message, Offset} when
694637
Rest :: unicode:unicode_binary(),

0 commit comments

Comments
 (0)