syntax.variable_keyword
A variable is declared with let, const or val, words from other languages, where Jadpo writes var.
Area 3, Logic; not declinable; the next step is usually the agent's.
Why Jadpo refuses it
Jadpo has one word for a variable: var name: Type = value, which never
changes, or var mut when it can. Other languages' words mean different
things from one language to the next, such as whether the value can
change, so Jadpo doesn't accept them and guess. The error names the word
to write, and the rest of the file is checked as if it were written.
What it looks like
main.jadpo:
type Count = Int { min: 0}function same(count: Count) -> Count { let kept: Count = count return kept}
error Jadpo writes var, not let
--> main.jadpo:6:5
|6 | let kept: Count = count | ^^^ write `var`
- reason
letdeclares a variable in JavaScript, TypeScript, Swift and Rust; a Jadpo variable isvar name: Type = value, orvar mutwhen it can change.- next
- Use
varinstead oflet(agent) - rule
- syntax.
variable_ keyword - help
- https://jadpo.
dev/docs/errors/syntax. variable_ keyword
(agent) at the end of the next: line means your coding agent can make
the fix itself.
const and val inside a body are the same error, and so is Rust's
let mut, whose Jadpo form is var mut. At the top of a file, outside any
function, const declares a fixed value, which Jadpo writes constant:
main.jadpo:
type Count = Int {}const limit: Count = 3function lim() -> Count { return limit}
error Jadpo writes constant, not const
--> main.jadpo:3:1
|3 | const limit: Count = 3 | ^^^^^ write `constant`
- reason
constdeclares a value that never changes in JavaScript, TypeScript, Rust, Go and C#; at the top of a Jadpo file a fixed value isconstant name: Type = value.- next
- Use
constantinstead ofconst(agent) - rule
- syntax.
variable_ keyword - help
- https://jadpo.
dev/docs/errors/syntax. variable_ keyword
How to fix it
If it is a variable in a body, write var, or var mut if you assign
it again later:
var kept: Count = countkept is a variable that never changes, and the function checks.
If it is a fixed value at the top of a file, write constant:
constant limit: Count = 3limit is a constant: a fixed value worked out while compiling, which
lim reads by name.
Related
Markdown for agents: /docs/errors/syntax.variable_keyword.md.Built from Jadpo main at aee2e8f.