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 @@ -3071,16 +3071,31 @@ class parser
30713071 -> void
30723072 {
30733073 auto m = std::string{msg};
3074- if (include_curr_token) {
3075- m += std::string (" (at '" ) + curr ().to_string (true ) + " ')" ;
3076- }
3077- if (
3078- err_pos == source_position{}
3079- && peek (0 )
3080- )
3081- {
3082- err_pos = peek (0 )->position ();
3074+
3075+ if (done ()) {
3076+ int i = 0 ;
3077+ while (!peek (i) && pos + i > 0 ) { --i; };
3078+ if (peek (i)) {
3079+ m += std::string (" (after '" ) + peek (i)->to_string (true ) + " ')" ;
3080+ if (
3081+ err_pos == source_position{}
3082+ ) {
3083+ err_pos = peek (i)->position ();
3084+ }
3085+ }
3086+ } else {
3087+ if (include_curr_token) {
3088+ m += std::string (" (at '" ) + curr ().to_string (true ) + " ')" ;
3089+ }
3090+ if (
3091+ err_pos == source_position{}
3092+ && peek (0 )
3093+ )
3094+ {
3095+ err_pos = peek (0 )->position ();
3096+ }
30833097 }
3098+
30843099 errors.emplace_back ( err_pos, m, false , fallback );
30853100 }
30863101
@@ -5086,7 +5101,8 @@ class parser
50865101
50875102 // If there's no [ [ then this isn't a contract
50885103 if (
5089- curr ().type () != lexeme::LeftBracket
5104+ done ()
5105+ || curr ().type () != lexeme::LeftBracket
50905106 || !peek (1 )
50915107 || peek (1 )->type () != lexeme::LeftBracket
50925108 )
You can’t perform that action at this time.
0 commit comments