Skip to content

[Feature Request][Compiler] Emit a compiler warning on inline function that use acquires #17123

@JakeSilverman

Description

@JakeSilverman

🚀 Feature Request

Emit a compiler warning on inline function that use acquires

Motivation

Acquires statements on inline functions do not affect the compiler semantics. For example, the following all behave the same:

Correct Acquire

module 0x42::M {

    struct Number has key {
        number: u64
    }


    struct Useless has key {
        number: u64
    }

    inline fun must_find_position(
        address: address
    ): u64 acquires Number {
        borrow_global<Number>(address).number
    }

    fun get_inner_value(
        address: address
    ): u64 acquires Number {
        must_find_position(address)
    }
}

No acquire

module 0x42::M {

    struct Number has key {
        number: u64
    }


    struct Useless has key {
        number: u64
    }

    inline fun must_find_position(
        address: address
    ): u64 {
        borrow_global<Number>(address).number
    }

    fun get_inner_value(
        address: address
    ): u64 acquires Number {
        must_find_position(address)
    }
}

Actively wrong acquire

module 0x42::M {

    struct Number has key {
        number: u64
    }


    struct Useless has key {
        number: u64
    }

    inline fun must_find_position(
        address: address
    ): u64 acquires Useless {
        borrow_global<Number>(address).number
    }

    fun get_inner_value(
        address: address
    ): u64 acquires Number {
        must_find_position(address)
    }
}

This is potentially confusing to people developing/reading the code.

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    For Grabs

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions