Skip to content

Commit cf73ace

Browse files
committed
Also solve the issue for interpolations.
1 parent 271556e commit cf73ace

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/elixir_transform.erl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,8 @@ transform({bin_element, Line, Expr, Type, Specifiers }, S) ->
339339
% = Variables
340340
%
341341
% No variables can be defined in a string without interpolation.
342-
transform({string, Line, String }, S) ->
343-
CharList = [{integer,Line,Integer} || Integer <- String],
344-
{ elixir_tree_helpers:build_simple_bin(Line, CharList), S };
342+
transform({string, Line, String } = Expr, S) ->
343+
{ elixir_tree_helpers:build_simple_bin(Line, [Expr]), S };
345344

346345
% Handle interpolated strings declarations.
347346
%

src/elixir_tree_helpers.erl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ build_bin_each(Fun, [], Line, S, Acc) ->
4444

4545
build_bin_each(Fun, [H|T], Line, S, Acc) ->
4646
{ Expr, NS, Format } = Fun(H, S),
47-
build_bin_each(Fun, T, Line, NS, [{ bin_element, Line, Expr, default, Format }|Acc]).
47+
case Expr of
48+
{string, _, String} ->
49+
Final = lists:foldl(fun(Integer, FinalAcc) ->
50+
[{bin_element,Line,{integer,Line,Integer},default,Format}|FinalAcc]
51+
end, Acc, String),
52+
build_bin_each(Fun, T, Line, NS, Final);
53+
_ ->
54+
build_bin_each(Fun, T, Line, NS, [{ bin_element, Line, Expr, default, Format }|Acc])
55+
end.
4856

4957
% Build simple binaries
5058
build_simple_bin(Line, Exprs) ->

0 commit comments

Comments
 (0)