#20457·aptos-core

[错误] [compiler-v2] 对具有扩展能力的函数值进行 `==`/`!=` 运算时,生成的字节码被验证器拒绝( `EQUALITY_OP_TYPE_MISMATCH_ERROR`)。

作者: vineethk创建于 2026年8月28日更新于 2026年8月28日
标签bugcompiler-v2
move
module 0xc0ffee::m {
    struct DropStore has drop, store { x: u64 }

    public fun with_capture(d: DropStore, y: u64): u64 {
        let DropStore { x } = d;
        x + y
    }

    public fun compare(d: DropStore, g: |u64|u64 has drop): bool {
        (|y| with_capture(d, y)) == g
    }
}

Output (fails at every optimization level):

Error: compilation errors:
 bug: bytecode verification failed with unexpected status code `EQUALITY_OP_TYPE_MISMATCH_ERROR`:
Error message: none
   ┌─ ...
   │
   │         (|y| with_capture(d, y)) == g
   │         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   │
   = please consider reporting this issue (see https://aptos.dev/en/build/smart-contracts/compiler_v2#reporting-an-issue)

The lambda's checked type unifies to |u64|u64 has drop (both == operands have identical source types), but the emitted pack_closure result carries the verifier-derived type: with_capture is public (persistent, so copy + drop + store) intersected with the captured DropStore (drop + store), giving |u64|u64 has drop + store. Generated bytecode:

内容来源: aptos-labs/aptos-core