@@ -972,8 +972,7 @@ defmodule Code do
972
972
@ doc since: "1.13.0"
973
973
@ spec string_to_quoted_with_comments ( List.Chars . t ( ) , keyword ) ::
974
974
{ :ok , Macro . t ( ) , list ( map ( ) ) } | { :error , { location :: keyword , term , term } }
975
- def string_to_quoted_with_comments ( string , opts \\ [ ] )
976
- when is_binary ( string ) and is_list ( opts ) do
975
+ def string_to_quoted_with_comments ( string , opts \\ [ ] ) when is_list ( opts ) do
977
976
charlist = to_charlist ( string )
978
977
file = Keyword . get ( opts , :file , "nofile" )
979
978
line = Keyword . get ( opts , :line , 1 )
@@ -1003,7 +1002,9 @@ defmodule Code do
1003
1002
@ doc since: "1.13.0"
1004
1003
@ spec string_to_quoted_with_comments! ( List.Chars . t ( ) , keyword ) :: { Macro . t ( ) , list ( map ( ) ) }
1005
1004
def string_to_quoted_with_comments! ( string , opts \\ [ ] ) do
1006
- case string_to_quoted_with_comments ( string , opts ) do
1005
+ charlist = to_charlist ( string )
1006
+
1007
+ case string_to_quoted_with_comments ( charlist , opts ) do
1007
1008
{ :ok , forms , comments } ->
1008
1009
{ forms , comments }
1009
1010
@@ -1013,7 +1014,7 @@ defmodule Code do
1013
1014
Keyword . get ( opts , :file , "nofile" ) ,
1014
1015
error ,
1015
1016
token ,
1016
- { string , Keyword . get ( opts , :line , 1 ) , Keyword . get ( opts , :column , 1 ) }
1017
+ { charlist , Keyword . get ( opts , :line , 1 ) , Keyword . get ( opts , :column , 1 ) }
1017
1018
)
1018
1019
end
1019
1020
end
0 commit comments