---
title: "MGS1051: a spell does not match the spell contract"
description: Fires when a spell exports an mgs_ function whose return type differs from the spell contract's, declares none or any, takes parameters, or is not a contract function at all. The spell does not load.
tags: [MGS1051, magusfile, spells, contract, mgs_]
---

# 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](../../spell-contract.md):

- it declares a return type other than the contract's, `> any` included;
- 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](../../spell-contract.md) lists each function's exact
  annotation, for example `export fun mgs_getLanguage() > Language`.
- **Return one shape per function.** A `> any` that mixes commands and services
  splits into `mgs_listTargets` and `mgs_listServices`.
- **Rename or remove an unknown function.** Fix a misspelling; delete a function
  the contract dropped.
