File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -880,6 +880,27 @@ impl<'a> Parser<'a> {
880
880
false
881
881
}
882
882
}
883
+
884
+ /// Expect and consume a `+`. if `+=` is seen, replace it with a `=`
885
+ /// and continue. If a `+` is not seen, return false.
886
+ ///
887
+ /// This is using when token splitting += into +.
888
+ /// See issue 47856 for an example of when this may occur.
889
+ fn eat_plus ( & mut self ) -> bool {
890
+ self . expected_tokens . push ( TokenType :: Token ( token:: BinOp ( token:: Plus ) ) ) ;
891
+ match self . token {
892
+ token:: BinOp ( token:: Plus ) => {
893
+ self . bump ( ) ;
894
+ true
895
+ }
896
+ token:: BinOpEq ( token:: Plus ) => {
897
+ let span = self . span . with_lo ( self . span . lo ( ) + BytePos ( 1 ) ) ;
898
+ self . bump_with ( token:: Eq , span) ;
899
+ true
900
+ }
901
+ _ => false ,
902
+ }
903
+ }
883
904
884
905
/// Expect and consume an `&`. If `&&` is seen, replace it with a single
885
906
/// `&` and continue. If an `&` is not seen, signal an error.
@@ -4801,7 +4822,7 @@ impl<'a> Parser<'a> {
4801
4822
break
4802
4823
}
4803
4824
4804
- if !allow_plus || !self . eat ( & token :: BinOp ( token :: Plus ) ) {
4825
+ if !allow_plus || !self . eat_plus ( ) {
4805
4826
break
4806
4827
}
4807
4828
}
You can’t perform that action at this time.
0 commit comments