[Bug] Errors happening in inline functions have confusing messages and don't have the right stack trace
movekevin opened this issue · comments
Example:
Code:
vector::for_each_ref(owners, |owner| {
assert!(owner != multisig_account, error::invalid_argument(EOWNER_CANNOT_BE_MULTISIG_ACCOUNT_ITSELF));
let (found, _) = vector::index_of(&distinct_owners, &owner);
assert!(!found, error::invalid_argument(EDUPLICATE_OWNER));
vector::push_back(&mut distinct_owners, owner);
});
This incorrectly compares owner (which is a &address) against multisig_account (which is an address).
Current error:
error[E04007]: incompatible types
┌─ /Users/kevin/aptos-core/aptos-move/framework/aptos-framework/sources/multisig_account.move:915:9
│
913 │ fun validate_owners(owners: &vector<address>, multisig_account: address) {
│ ------- Expected: 'address'
914 │ let distinct_owners: vector<address> = vector[];
915 │ ╭ vector::for_each_ref(owners, |owner| {
916 │ │ assert!(owner != multisig_account, error::invalid_argument(EOWNER_CANNOT_BE_MULTISIG_ACCOUNT_ITSELF));
917 │ │ let (found, _) = vector::index_of(&distinct_owners, &owner);
918 │ │ assert!(!found, error::invalid_argument(EDUPLICATE_OWNER));
919 │ │ vector::push_back(&mut distinct_owners, owner);
920 │ │ });
│ ╰──────────^ Invalid call of '(std=0x1)::vector::for_each_ref'. Invalid argument for parameter 'f'
Desired error:
^^ ----- Found: '&address'. It is not compatible with the other type.
│ │
│ Incompatible arguments to '!='
Can you please re-open in aptos-core and assign Move project for triage (do not yet assign to me ;-))