Typed holes
Where you don't know which value goes in a place, write _ there and run
jadpo check. The answer is the error type.hole: the type the place
requires, written as the code would write it, and up to five values that
fit, closest first, with the edit that writes the closest.
type BookTitle = Text { max_length: 200}type Book = Object { title: BookTitle author: PersonName}function shelve(title: BookTitle, author: PersonName) -> Book { return Book { title: title author: _ }}
error: `_` stands for a `PersonName` --> main.jadpo:13:17 |13 | author: _ | ^ a `PersonName` goes here reason: `PersonName` is an object: `PersonName { given: GivenName, family: FamilyName? }`. In scope, `author` fits. next: Write `author` (agent) fix: 13 - author: _ 13 + author: author rule: type.hole help: https://jadpo.dev/docs/errors/type.holecheck failed: 1 error, 1 filenext: jadpo fix fixes this error for you, then checks again
- Where it goes.
_stands where a value goes: an argument, a field of an object being built, areturn, avar's value or aset:line. It is never a type or a pattern; in amatcharm's pattern_is the wildcard, as before. - What fits, closest first. The locals and parameters in scope,
nearest first; their fields, one level down (
input.name); the constants the code can read;clock.nowwhere the code may read the clock; then a standard operation or a library function whose result fits and whose every argument is a value in scope, written with them, fewest arguments first. An operation that can fail needsattempt, so it isn't offered. - When nothing fits. An object is written out with a
_for each field that can't benoneandnonefor the rest, so the next check answers each of those holes in turn; a standard type's next step namesjadpo help <Type>. - Where nothing says the type, as in
_ + 1or_.count, the error says so: declare the value with its type first,var name: Type = _. - It can never ship. A hole is an error like every other finding and can't be declined, so a project holding one never checks, runs its tests or builds, and the code around it isn't reported unused while it is there.
jadpo check --json gives the type as expected and the values as
fits, each with its text, its type and the edit that writes it, and
hovering over the _ in the editor shows the same.
Markdown for agents: /docs/typed-holes.md.Built from Jadpo's main branch at commit 9080dc3.