noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
887 stars 196 forks source link

Nargo fmt incorrectly formats nested structures #4462

Closed LogvinovLeon closed 2 weeks ago

LogvinovLeon commented 8 months ago

Aim

Format this code:

    assert_eq(
        result, [
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2
        ]
    );

Expected Behavior

Do nothing

Bug

nargo fmt removes one level of tabs incorrectly

    assert_eq(
        result, [
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2
    ]
    );

To Reproduce

  1. Copy this code part
  2. Run nargo fmt

Project Impact

Nice-to-have

Impact Context

Very low pri

Workaround

None

Workaround Description

No response

Additional Context

No response

Installation Method

Binary (noirup default)

Nargo Version

noirc version = 0.23.0+5be9f9d7e2f39ca228df10e5a530474af0331704

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

LogvinovLeon commented 8 months ago

This also shows in imports:

use crate::fixtures::{
    london::crypto_punks::header::{block_header_partial as london_block_header_partial, block_header_rlp as london_block_header_rlp},
    frontier::zero::header::{
    block_header_partial as frontier_zero_block_header_partial,
    block_header_rlp as frontier_zero_block_header_rlp
},
    frontier::first::header::{
    block_header_partial as frontier_first_block_header_partial,
    block_header_rlp as frontier_first_block_header_rlp
},
    paris::usdc::header::{block_header_partial as paris_block_header_partial, block_header_rlp as paris_block_header_rlp},
    paris::usdc::header::{hash, number, state_root, transactions_root, receipts_root}
};