E1007: binding dropped twice

View source

A resource is released exactly once (ADR-0027).

A resource is released exactly once (ADR-0027). The compiler rejects a drop of a binding that was already dropped. Dropping a binding that was moved is a use of a moved binding and is reported as E1005 instead. The error points at the second drop.

Example

actus
verb main() {
    erg data: Buffer = Buffer[4];
    drop(data);
    drop(data);
}

Fix

Drop the binding once. Without an explicit drop, the compiler releases it when its scope ends.

actus
verb main() {
    erg data: Buffer = Buffer[4];
    drop(data);
}

A binding from which a field was moved is dropped once for its remaining fields:

actus
struct Config {
    erg first: Buffer,
    erg second: Buffer,
}

verb release(dat held: Buffer) {
    drop(held);
}

verb main() {
    erg config: Config = Config { first: Buffer[4], second: Buffer[4], };
    release(held: dat config.first);
    drop(config);
}

Run actus explain E1007 in your terminal to read this entry offline. Browse Ownership & types or all error codes.