feat(lang): a name is defined once, a local once per block, and a result is always returned
L1. Two vars, consts, enums, properties or events of one name in a program are an error naming both places (functions already were); the first used to win silently. A let / var of a name its own block already declared is an error (it used to shadow). A function with a result type whose body can reach its end without a return is an error, asked structurally of the body - a return, an if/else or a match with a default arm whose every branch ends - rather than handing back whatever the result slot held. The game, the lab and every package example pass all three; the lab had one harmless shadow, and the game's split screens had two real bugs of the kind. examples/rejected/ holds the four refusals, checked by the test runner's new reject_case. Seed regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c57eafcacc
commit
dc75a5a5ab
13 changed files with 46652 additions and 44931 deletions
|
|
@ -62,6 +62,14 @@ parse:
|
|||
chronorift/world.ludic:1: error: expected expression
|
||||
```
|
||||
|
||||
All of a program's files share one namespace, so **a name is defined once**: two functions, two
|
||||
`var`s or `const`s (or an `enum` and a `const`), or two `property` / `event` records with one name
|
||||
are an error that names both places. Declarations the runtime splices in are its own and are not
|
||||
checked against each other.
|
||||
The same holds inside a function: a `let` or `var` declares its name once per block (another
|
||||
block, a loop variable or a parameter may reuse it), and a function with a result type must
|
||||
`return` one on every path - running off the end of its body is an error, not a zero.
|
||||
|
||||
## Models (entity kinds)
|
||||
|
||||
An `model` names a *kind* of entity and the fixed set of properties it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue