aptos-labs / aptos-core

Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
https://aptosfoundation.org
Other
6.12k stars 3.62k forks source link

[Bug] `aptos move fmt` does not support Move 2 #14810

Closed alnoki closed 3 hours ago

alnoki commented 3 hours ago

@wrwg I can format this with movefmt but not with aptos move fmt:

module hello_wolfgang::red_black_map {
    enum Color {
        Red,
        Black
    }

    struct Node<V> {
        key: u256,
        value: V,
        color: Color
    }
}

aptos move fmt throws:

error[E01002]: unexpected token
  ┌─ /a/file-path/
  │
2 │     enum Color {
  │     ^^^^
  │     │
  │     Unexpected 'enum'
  │     Expected a module member: 'spec', 'use', 'friend', 'const', 'fun', 'inline', or 'struct'

Perhaps there could be some kind of passthrough option that lets the CLI user choose which movefmt is in use? Or maybe a CI action @banool that can package the latest stable movefmt version with each aptos release?

rahxephon89 commented 3 hours ago

Hi @alnoki, 1.0.5 supports move 2, you can use aptos update movefmt --target-version 1.0.5 to install the latest version: https://github.com/movebit/movefmt/issues/38