mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
fix(es/minifier): Don't convert a signed integer literal key to a numeric literal (#6529)
**Related issue:** - Closes https://github.com/swc-project/swc/issues/6528.
This commit is contained in:
parent
6ca36c198b
commit
81224b5d67
@ -95,7 +95,7 @@ impl Pure<'_> {
|
||||
return;
|
||||
}
|
||||
|
||||
if !s.value.starts_with('0') || s.value.len() <= 1 {
|
||||
if (!s.value.starts_with('0') && !s.value.starts_with('+')) || s.value.len() <= 1 {
|
||||
if let Ok(v) = s.value.parse::<u32>() {
|
||||
self.changed = true;
|
||||
report_change!("misc: Optimizing numeric property name");
|
||||
|
@ -10374,3 +10374,23 @@ fn issue_6463_1() {
|
||||
"###,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_6528() {
|
||||
run_default_exec_test(
|
||||
r###"
|
||||
const foo = {
|
||||
"+1": 1,
|
||||
"2": 2,
|
||||
"-3": 3,
|
||||
}
|
||||
|
||||
console.log(foo[1]);
|
||||
console.log(foo["+1"]);
|
||||
console.log(foo["2"]);
|
||||
console.log(foo[2]);
|
||||
console.log(foo[-3]);
|
||||
console.log(foo["-3"]);
|
||||
"###,
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user