Commit 84c6418
authored
Enable local variables in functions (#1023)
Closes keyboardDrummer#24
## Changes
**LaurelToCoreTranslator.lean**: In the `translateExpr` case for `Block`
with `LocalVariable` (with initializer), replaced the `disallowed` error
with the actual translation:
```lean
let coreMonoType ← translateType ty
return .app () (.abs () name.text (some coreMonoType) bodyExpr) valueExpr
```
This encodes `var x: T := v; body` as the beta-redex `(λ x:T. body) v`,
which the Core evaluator already handles via beta reduction, and the
`Preconditions` module already handles as a let-binding pattern.
**T3_ControlFlowError.lean**: Removed the three `error: local variables
in functions are not YET supported` annotations and the associated
comments, since local variables in functions are now supported.
## Verification
- `LaurelToCoreTranslator` builds successfully
- All Laurel fundamental tests pass (`T1` through `T21`)
- All transform tests pass
Co-authored-by: keyboardDrummer-bot <keyboardDrummer-bot@users.noreply.github.com>1 parent bab843c commit 84c6418
2 files changed
Lines changed: 2 additions & 9 deletions
File tree
- StrataTest/Languages/Laurel/Examples/Fundamentals
- Strata/Languages/Laurel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
| 278 | + | |
| 279 | + | |
282 | 280 | | |
283 | 281 | | |
284 | 282 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | 25 | | |
28 | 26 | | |
29 | | - | |
30 | 27 | | |
31 | | - | |
32 | 28 | | |
33 | | - | |
34 | 29 | | |
35 | 30 | | |
36 | 31 | | |
| |||
0 commit comments