You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extends --translate to module-level value bindings: `let <id> = <literal>`
becomes a typed AffineScript `const`, since AffineScript has no module-level
`let` (a top-level value binding is `const name: Type = value;`).
let answer = 42 -> const answer: Int = 42;
let pi = 3.14 -> const pi: Float = 3.14;
let greeting = "hi" -> const greeting: String = "hi";
let enabled = true -> const enabled: Bool = true;
Conservative: only int/float/string/bool literals (type inferred, const
type-checks standalone). A call body, a `ref(...)` mutable-global, a
destructuring pattern, or an exotic number (hex/signed/scientific/underscored)
is skipped — left as marker + quoted original, never a wrong const. Number
forms limited to plain decimal int and D+.D+ float.
Walker-internal (translate_literal / classify_number / translate_let_const +
a let_declaration branch in collect_translations); Walker.translate /
Emitter.emit_translation signatures unchanged.
Scope boundary documented: switch->match (an expression needing whole-function
translation of un-annotated ReScript fns) and qualified-path resolution stay
out of the "every emitted form type-checks" scope.
Verified locally with the apt-bootstrapped toolchain: full `dune build` exit 0;
22 res-to-affine walker tests green (4 new) against pinned grammar 990214a;
`main.exe check` on the generated consts returns Type checking passed.
Refs #57https://claude.ai/code/session_017T8SzHr2yXav8hm4Ho76Uw
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ this project aims to follow [Semantic Versioning](https://semver.org/spec/v2.0.0
20
20
21
21
### Added
22
22
23
+
- feat(res-to-affine): Phase 3 slice 3 — `--translate` now also lowers module-level `let <id> = <literal>` (int/float/string/bool) to a typed `const name: T = value;`; call / `ref(...)` / destructuring bindings are skipped (not compile-time constants); every emitted form verified compilable via `main.exe check`. `switch`→`match` and qualified-path resolution remain out of the standalone-type-check scope (Refs #57)
23
24
- feat(res-to-affine): Phase 3 slice 2 — `--translate` now also handles record types (→ `struct`) and generics (type params `'a` → `[A]`) across aliases / sums / records; `mutable`/optional-`?` records, qualified paths, and nested generics are still skipped (never guessed); every emitted form verified compilable via `main.exe check` (Refs #57)
24
25
- feat(res-to-affine): Phase 3 slice 1 — `--translate` renders fully-structural type declarations (primitive aliases + simple sum types) into compilable AffineScript; conservative (generics / qualified paths / records / non-primitive payloads are skipped, never guessed); walker-only (Refs #57)
0 commit comments