-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix JSON deserialization of AssignExpr #5179
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove images
7106287
to
8881aa9
Compare
Oops sorry I based this on wrong branch. Have pushed again with just the relevant commit. |
Is there a case where Oh, it may be |
I think |
It seems a lot of work to do if I remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
swc-bump:
- swc_ecma_ast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Automated review comment generated by auto-rebase script
I've made the changes requested and tidied up some other bits. I'm still not completely happy with this: if let PatOrExpr::Pat(ref pat) = left {
if let Pat::Ident(ident) = &**pat {
left = PatOrExpr::Expr(Box::new(Expr::Ident(ident.id.clone())));
}
} The My first attempt was: left = match left {
PatOrExpr::Pat(pat) => match *pat {
Pat::Ident(ident) => PatOrExpr::Expr(Box::new(Expr::Ident(ident.id))),
pat => PatOrExpr::Pat(Box::new(pat)),
},
left => left,
} This avoids cloning as it takes ownership, but has the worse consequences of unclear code and re-creating Or am I worrying too much? Will the compiler compile away the |
I think so? |
Is there no way to tell compiler "give me ownership of |
Description:
Fix for #5168. However:
match { }
here:https://github.com/overlookmotel/swc/blob/assign-expr-deserialize/crates/swc_ecma_ast/src/expr.rs#L568-L576
I would appreciate any pointers as to how to improve this.
Related issue (if exists):
#5168