@@ -3,7 +3,7 @@ use std::error::Error;
33use oxc:: {
44 allocator:: { Allocator , StringBuilder } ,
55 ast:: ast:: {
6- AssignmentExpression , AssignmentTarget , CallExpression , ComputedMemberExpression , DebuggerStatement , ExportAllDeclaration , ExportNamedDeclaration , Expression , FunctionBody , IdentifierReference , ImportDeclaration , ImportExpression , MemberExpression , MetaProperty , NewExpression , ObjectExpression , ObjectPropertyKind , ReturnStatement , StringLiteral , ThisExpression , UnaryExpression , UnaryOperator , UpdateExpression
6+ AssignmentExpression , AssignmentTarget , BindingPattern , CallExpression , ComputedMemberExpression , DebuggerStatement , ExportAllDeclaration , ExportNamedDeclaration , Expression , FunctionBody , IdentifierReference , ImportDeclaration , ImportExpression , MemberExpression , MetaProperty , NewExpression , ObjectExpression , ObjectPattern , ObjectPropertyKind , ReturnStatement , SimpleAssignmentTarget , StringLiteral , ThisExpression , UnaryExpression , UnaryOperator , UpdateExpression
77 } ,
88 ast_visit:: { walk, Visit } ,
99 span:: { Atom , GetSpan , Span } ,
@@ -291,9 +291,24 @@ where
291291 walk:: walk_unary_expression ( self , it) ;
292292 }
293293
294- // fn visit_update_expression(&mut self, _it: &UpdateExpression<'data>) {
295- // // this is like a ++ or -- operator
296- // }
294+ fn visit_update_expression ( & mut self , it : & UpdateExpression < ' data > ) {
295+ // this is like a ++ or -- operator
296+ match it. argument {
297+ SimpleAssignmentTarget :: AssignmentTargetIdentifier ( _) => {
298+ // if it's an identifier we cannot rewrite it
299+ // $wrap(location)++ is invalid syntax
300+
301+ // so it's safer to assume that this "location" is a local
302+ // even if it's real location you can't escape with it anyway
303+ // unless you consider navigating to "https://proxy.com/NaN" escaping
304+ return ;
305+ }
306+ _=>{ }
307+ }
308+
309+ // if it's not a simple identifier it's probably a member expression which is safe
310+ walk:: walk_update_expression ( self , it) ;
311+ }
297312
298313 fn visit_meta_property ( & mut self , it : & MetaProperty < ' data > ) {
299314 if it. meta . name == "import" {
0 commit comments