File tree Expand file tree Collapse file tree 1 file changed +26
-10
lines changed
Expand file tree Collapse file tree 1 file changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -2853,16 +2853,31 @@ class parser
28532853 -> void
28542854 {
28552855 auto m = std::string{msg};
2856- if (include_curr_token) {
2857- m += std::string (" (at '" ) + curr ().to_string (true ) + " ')" ;
2858- }
2859- if (
2860- err_pos == source_position{}
2861- && peek (0 )
2862- )
2863- {
2864- err_pos = peek (0 )->position ();
2856+
2857+ if (done ()) {
2858+ int i = 0 ;
2859+ while (!peek (i) && pos + i > 0 ) { --i; };
2860+ if (peek (i)) {
2861+ m += std::string (" (after '" ) + peek (i)->to_string (true ) + " ')" ;
2862+ if (
2863+ err_pos == source_position{}
2864+ ) {
2865+ err_pos = peek (i)->position ();
2866+ }
2867+ }
2868+ } else {
2869+ if (include_curr_token) {
2870+ m += std::string (" (at '" ) + curr ().to_string (true ) + " ')" ;
2871+ }
2872+ if (
2873+ err_pos == source_position{}
2874+ && peek (0 )
2875+ )
2876+ {
2877+ err_pos = peek (0 )->position ();
2878+ }
28652879 }
2880+
28662881 errors.emplace_back ( err_pos, m, false , fallback );
28672882 }
28682883
@@ -4890,7 +4905,8 @@ class parser
48904905
48914906 // If there's no [ [ then this isn't a contract
48924907 if (
4893- curr ().type () != lexeme::LeftBracket
4908+ done ()
4909+ || curr ().type () != lexeme::LeftBracket
48944910 || !peek (1 )
48954911 || peek (1 )->type () != lexeme::LeftBracket
48964912 )
You can’t perform that action at this time.
0 commit comments