{"id":"word--requires","name":"requires","owner":"yeho","package":"language","kind":"keyword","signature":"requires","description":"Declare a precondition","context":"Use contracts at important boundaries where callers and maintainers need one visible definition of correctness.","parameters":[],"returns":"","members":[],"tags":["complete-program","cpu","functions","keyword","yeho"],"updated":"2026-09-09","source":{"repository":"yeho","path":"parser_declarations.cpp parseContractClauses and parseThingInvariant; conformance errors-contracts"},"status":"experimental","notes":["Errors and contracts are experimental in the current conformance edition.","Keep the condition deterministic and cheap enough to be useful as evidence."],"examples":[{"id":"complete","title":"Contract pass","description":"Use contracts at important boundaries where callers and maintainers need one visible definition of correctness.","code":"Increment(int value) returns int\nrequires(value > 0)\nensures(result == value + 1)\n{\n    return value + 1\n}\n\nConsole.Log(Text.From(Increment(4)))\n","manifest":"package = \"tests.compiler.errorsTasksEffects.contractPass\"\nversion = \"0.1.0\"\nbackend = \"cpu-oracle\"\nosTarget = \"windows\"\narchTarget = \"x64\"\nselfContainedApp = false\n","tags":["cpu","complete-program"],"verification":"type checked","run":"cpu-oracle","source":"tests/compiler/errors-tasks-effects/contract-pass/start.yh","sha256":"7596733f355e82045916ad1e562cd4626d8883b61d0d8037ca088e9300e1733e","checked":"2026-09-09","diagnostic":"","observedOutput":null,"checkedBackend":null}],"searchTerms":[],"url":"https://demonhunterlabs.com/academy/api?item=word--requires","json":"https://demonhunterlabs.com/reference/items/word--requires.json","markdown":"https://demonhunterlabs.com/reference/text/word--requires.md"}
