@@ -142,18 +142,20 @@ tokenize([], Line, Column, #elixir_tokenizer{cursor_completion=Cursor} = Scope,
142142 AccTokens = cursor_complete (Line , CursorColumn , CursorTerminators , CursorTokens ),
143143 {ok , Line , Column , AllWarnings , AccTokens };
144144
145- tokenize ([], EndLine , _ , # elixir_tokenizer {terminators = [{Start , {StartLine , StartColumn , _ }, _ } | _ ]} = Scope , Tokens ) ->
145+ tokenize ([], EndLine , EndColumn , # elixir_tokenizer {terminators = [{Start , {StartLine , StartColumn , _ }, _ } | _ ]} = Scope , Tokens ) ->
146146 End = terminator (Start ),
147147 Hint = missing_terminator_hint (Start , End , Scope ),
148148 Message = " missing terminator: ~ts " ,
149149 Formatted = io_lib :format (Message , [End ]),
150150 Meta = [
151- {error_type , unclosed_delimiter },
152- {opening_delimiter , Start },
153- {line , StartLine },
154- {column , StartColumn },
155- {end_line , EndLine }
156- ],
151+ {error_type , unclosed_delimiter },
152+ {opening_delimiter , Start },
153+ {expected_delimiter , End },
154+ {line , StartLine },
155+ {column , StartColumn },
156+ {end_line , EndLine },
157+ {end_column , EndColumn }
158+ ],
157159 error ({Meta , [Formatted , Hint ], []}, [], Scope , Tokens );
158160
159161tokenize ([], Line , Column , # elixir_tokenizer {} = Scope , Tokens ) ->
@@ -531,7 +533,7 @@ tokenize([$:, H | T] = Original, Line, Column, Scope, Tokens) when ?is_quote(H)
531533
532534 {error , Reason } ->
533535 Message = " (for atom starting at line ~B )" ,
534- interpolation_error (Reason , Original , Scope , Tokens , Message , [Line ])
536+ interpolation_error (Reason , Original , Scope , Tokens , Message , [Line ], Line , Column + 1 , [ H ], [ H ] )
535537 end ;
536538
537539tokenize ([$: | String ] = Original , Line , Column , Scope , Tokens ) ->
@@ -772,7 +774,7 @@ handle_heredocs(T, Line, Column, H, Scope, Tokens) ->
772774handle_strings (T , Line , Column , H , Scope , Tokens ) ->
773775 case elixir_interpolation :extract (Line , Column , Scope , true , T , H ) of
774776 {error , Reason } ->
775- interpolation_error (Reason , [H | T ], Scope , Tokens , " (for string starting at line ~B )" , [Line ]);
777+ interpolation_error (Reason , [H | T ], Scope , Tokens , " (for string starting at line ~B )" , [Line ], Line , Column - 1 , [ H ], [ H ] );
776778
777779 {NewLine , NewColumn , Parts , [$: | Rest ], InterScope } when ? is_space (hd (Rest )) ->
778780 NewScope = case is_unnecessary_quote (Parts , InterScope ) of
@@ -925,7 +927,7 @@ handle_dot([$., H | T] = Original, Line, Column, DotInfo, Scope, Tokens) when ?i
925927 Message = " interpolation is not allowed when calling function/macro. Found interpolation in a call starting with: " ,
926928 error ({? LOC (Line , Column ), Message , [H ]}, Rest , NewScope , Tokens );
927929 {error , Reason } ->
928- interpolation_error (Reason , Original , Scope , Tokens , " (for function name starting at line ~B )" , [Line ])
930+ interpolation_error (Reason , Original , Scope , Tokens , " (for function name starting at line ~B )" , [Line ], Line , Column , [ H ], [ H ] )
929931 end ;
930932
931933handle_dot ([$. | Rest ], Line , Column , DotInfo , Scope , Tokens ) ->
@@ -1030,16 +1032,7 @@ extract_heredoc_with_interpolation(Line, Column, Scope, Interpol, T, H) ->
10301032 {ok , NewLine , NewColumn , tokens_to_binary (Parts2 ), Rest , NewScope };
10311033
10321034 {error , Reason } ->
1033- {Position , Message , List } = interpolation_format (Reason , " (for heredoc starting at line ~B )" , [Line ]),
1034- {line , EndLine } = lists :keyfind (line , 1 , Position ),
1035- Meta = [
1036- {error_type , unclosed_delimiter },
1037- {opening_delimiter , '"""' },
1038- {line , Line },
1039- {column , Column },
1040- {end_line , EndLine }
1041- ],
1042- {error , {Meta , Message , List }}
1035+ {error , interpolation_format (Reason , " (for heredoc starting at line ~B )" , [Line ], Line , Column , [H , H , H ], [H , H , H ])}
10431036 end ;
10441037
10451038 error ->
@@ -1352,12 +1345,21 @@ previous_was_eol(_) -> nil.
13521345
13531346% % Error handling
13541347
1355- interpolation_error (Reason , Rest , Scope , Tokens , Extension , Args ) ->
1356- error (interpolation_format (Reason , Extension , Args ), Rest , Scope , Tokens ).
1348+ interpolation_error (Reason , Rest , Scope , Tokens , Extension , Args , Line , Column , Opening , Closing ) ->
1349+ error (interpolation_format (Reason , Extension , Args , Line , Column , Opening , Closing ), Rest , Scope , Tokens ).
13571350
1358- interpolation_format ({string , Line , Column , Message , Token }, Extension , Args ) ->
1359- {? LOC (Line , Column ), [Message , io_lib :format (Extension , Args )], Token };
1360- interpolation_format ({_ , _ , _ } = Reason , _Extension , _Args ) ->
1351+ interpolation_format ({string , EndLine , EndColumn , Message , Token }, Extension , Args , Line , Column , Opening , Closing ) ->
1352+ Meta = [
1353+ {error_type , unclosed_delimiter },
1354+ {opening_delimiter , list_to_atom (Opening )},
1355+ {expected_delimiter , list_to_atom (Closing )},
1356+ {line , Line },
1357+ {column , Column },
1358+ {end_line , EndLine },
1359+ {end_column , EndColumn }
1360+ ],
1361+ {Meta , [Message , io_lib :format (Extension , Args )], Token };
1362+ interpolation_format ({_ , _ , _ } = Reason , _Extension , _Args , _Line , _Column , _Opening , _Closing ) ->
13611363 Reason .
13621364
13631365% % Terminators
@@ -1429,15 +1431,16 @@ check_terminator({End, {EndLine, EndColumn, _}}, [{Start, {StartLine, StartColum
14291431 End ->
14301432 {ok , Scope # elixir_tokenizer {terminators = Terminators }};
14311433
1432- _ExpectedEnd ->
1434+ ExpectedEnd ->
14331435 Meta = [
14341436 {line , StartLine },
14351437 {column , StartColumn },
14361438 {end_line , EndLine },
14371439 {end_column , EndColumn },
14381440 {error_type , mismatched_delimiter },
14391441 {opening_delimiter , Start },
1440- {closing_delimiter , End }
1442+ {closing_delimiter , End },
1443+ {expected_delimiter , ExpectedEnd }
14411444 ],
14421445 {error , {Meta , unexpected_token_or_reserved (End ), [atom_to_list (End )]}}
14431446 end ;
@@ -1490,7 +1493,6 @@ terminator('do') -> 'end';
14901493terminator ('(' ) -> ')' ;
14911494terminator ('[' ) -> ']' ;
14921495terminator ('{' ) -> '}' ;
1493- terminator ('"""' ) -> '"""' ;
14941496terminator ('<<' ) -> '>>' .
14951497
14961498% % Keywords checking
@@ -1596,7 +1598,7 @@ tokenize_sigil_contents([H | T] = Original, [S | _] = SigilName, Line, Column, S
15961598 {error , Reason } ->
15971599 Sigil = [$~ , S , H ],
15981600 Message = " (for sigil ~ts starting at line ~B )" ,
1599- interpolation_error (Reason , [$~ ] ++ SigilName ++ Original , Scope , Tokens , Message , [Sigil , Line ])
1601+ interpolation_error (Reason , [$~ ] ++ SigilName ++ Original , Scope , Tokens , Message , [Sigil , Line ], Line , Column , [ H ], [ sigil_terminator ( H )] )
16001602 end ;
16011603
16021604tokenize_sigil_contents ([H | _ ] = Original , SigilName , Line , Column , Scope , Tokens ) ->
0 commit comments