Skip to content

[Bug] [Decompiler Bug] Incorrectly handled case during control flow structuring #17087

@junxzm1990

Description

@junxzm1990

🐛 Bug

The decompiler decompiles the following code (ref: decompiler test case vector.move)

public fun contains<Element>(self: &vector<Element>, e: &Element): bool {
        let i = 0;
        let len = length(self);
        while (i < len) {
            if (borrow(self, i) == e) return true;
            i = i + 1;
        };
        false
}

==>

public fun contains<Element>(self: &vector<Element>, e: &Element): bool {
        let _t2;
        _t2 = 0;
        while (!(!(_t2 < length<Element>(self)) || borrow<Element>(self, _t2) == e)) _t2 = _t2 + 1;
        true
    }

The function will always return true, deviating from the original code. There are many similar cases. This bug is attributed to some issues in the initial control flow structuring.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions