MGS1051: a spell does not match the spell contract
magus refuses to load a spell when one of its exported mgs_ functions does
not match the spell contract:
- it declares a return type other than the contract's,
> anyincluded; - it declares no return type;
- it takes parameters;
- its name is not a contract function, such as a misspelling or a function the contract no longer has.
magus reads each function's return annotation from the spell's source before it calls any of them. The error lists every violation with its line.
Why
magus decodes each mgs_ value into the type the contract names. The Buzz
checker checks a function body against its own annotation, but nothing else
checks that annotation against the contract, so a spell declaring > any hands
magus a value whose shape nothing checked. A function the contract does not list
is a declaration magus would silently ignore.
Resolution
- Declare the contract's return type. The
spell contract lists each function's exact
annotation, for example
export fun mgs_getLanguage() > Language. - Return one shape per function. A
> anythat mixes commands and services splits intomgs_listTargetsandmgs_listServices. - Rename or remove an unknown function. Fix a misspelling; delete a function the contract dropped.