fix(es/minifier): Handle toExponential(undefined)#11583
fix(es/minifier): Handle toExponential(undefined)#11583cuyl wants to merge 2 commits intoswc-project:mainfrom
toExponential(undefined)#11583Conversation
|
Binary Sizes
Commit: 035bdb0 |
b737d27 to
2b02292
Compare
|
Opps, let me see if I can find a way to remove clone. |
2b02292 to
0e614e3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e614e347d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
0e614e3 to
c72e302
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c72e302ce2
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
Does anything block this PR? |
kdy1
left a comment
There was a problem hiding this comment.
AI coding is fine, but well... the diff in this PR does not look fine
| /// evaluate it. | ||
| /// | ||
| /// `None` means that there is no argument. | ||
| fn get_first_arg<'a>( |
There was a problem hiding this comment.
Opps, Should I revert it? I just want to remove the clone as you requested.
At first time I tried to add lifetime to prevent the clone, but I got an error.
error: reached the recursion limit while instantiating `get_first_arg::<'_, std::iter::Map<std::slice::Iter<'_, std::option::Option<swc_ecma_ast::ExprOrSpread>>, {closure@...}>>`
The code is here.
fn get_first_arg<'a, I>(args: I, expr_ctx: &ExprCtx) -> Option<Option<f64>>
where
I: IntoIterator<Item = Option<&'a ExprOrSpread>>,
{
args.into_iter()
.find_map(|arg| {
if let Some(arg) = arg {
if arg.spread.is_some() {
return match arg.expr.as_array() {
Some(args) => {
if args.elems.is_empty() {
// next argument is used if the first spread argument is empty
// so we can't evaluate the call.
None
} else {
Some(get_first_arg(
args.elems.iter().map(|e| e.as_ref()),
expr_ctx,
))
}
}
// If the spread argument is not an array, we can't evaluate the call.
None => Some(None),
};
} else if !arg.expr.is_undefined(*expr_ctx) {
return Some(Some(eval_as_number(*expr_ctx, &arg.expr)));
}
}
Some(None)
})
.unwrap_or(None)
}To resolve the error, I've using AI to refactor it to the non-recursion version.
There was a problem hiding this comment.
But AI can't make it right, so I changed some logic to make it right.
undefined.Closes #11572