movebit / movefmt

Other
5 stars 4 forks source link

Optimize the formatting logic of complex tuple #24

Closed robinlzw closed 3 months ago

robinlzw commented 4 months ago

In some scenarios, elements within tuples are complex expressions.

module 0x8675309::M {
    struct R {}

    fun t0() {
        ({
                let x = 0;
                x
            }: u64);
        ({
                let x = 0;
                &x
            }: &u64);
        ({
                let y = 0;
                &mut (y + 1)
            }: &mut u64);
        R {} = ({
                let r = {
                    let r = R {};
                    r
                };
                r
            }: R);
        ({
                let x = 0;
                (x, false)
            }: (u64, bool));
    }
}
robinlzw commented 3 months ago

fixed at https://github.com/movebit/movefmt/commit/89ba14f9e37c998774887b49d3a4176ae11a8ff5; and you can see more effects through this link https://github.com/movebit/aptos_move_dataset/blob/a76e7ccddfd1d5a786cfa1e765a02cf6b4452c54/after_fmt-240718/block_with_statements.move