putoutjs / minify

Minify with help of 🐊Putout
MIT License
12 stars 3 forks source link

Bug: Minify gives same name to multiple different variables. #6

Closed ybouane closed 11 months ago

ybouane commented 11 months ago

This code:

import { minify } from '@putout/minify';

console.log(
  minify(`
    let aaaaa = 5;
    fn((a)=>{
        console.log(aaaaa);
        console.log(a);
    });
`)
);

Outputs:

let a=5;fn(a=>{console.log(a);console.log(a)});

aaaaa is renamed into a but in the callback function, the argument a isn't renamed into something different.

coderaiser commented 11 months ago

Just fixed in @putout/minify@2.9.0 πŸŽ‰. Is it working for you now?

ybouane commented 11 months ago

There still seems to be issues, here's another example:

import { minify } from "@putout/minify";

console.log(
  minify(`
    let aaa = 5;
    fn((a, b)=>{
        console.log(b, aaa);
    });
`),
);

it minifies it to: let a=5;fn((a,b)=>console.log(b,a));

coderaiser commented 11 months ago

Just fixed in @putout/minify@2.10.0 πŸŽ‰. Is it working for you now?

ybouane commented 11 months ago

Yes, it seems to be working! Here's another case that can be further improved:

import { minify } from "@putout/minify";

console.log(
  minify(`
    let aaa = 5;
    fn(()=>{
        console.log(aaa, a);
    });
`),
);

outputs: let a=5;fn(()=>console.log(a,a));

coderaiser commented 11 months ago

Just fixed in @putout/minify@2.11.0 πŸŽ‰. Is it working for you now?

ybouane commented 11 months ago

Perfect!