Feat/oxabl semantic phase4b#50
Merged
Merged
Conversation
…ing (Phase 4a)
Walks every expression in the program, consults the scope chain with
namespace narrowing, and populates the `references: IndexVec<NodeId,
Option<Resolution>>` side table. Mirrors the declare-pass traversal so
both phases share the same scope-opening invariants without a second
NodeId → ScopeId side map.
Signature typing: every declaration with a known type emits an entry
in
`types[decl.id]`, including class-typed declarations upgraded from
`Unknown` to `Class(SymbolId)` when the referenced class is declared
locally. Cross-file / USING-imported class types stay `Unknown` and
are
treated as `External` by downstream lint rules.
Read/write counts are accumulated into a local map and written to each
`Symbol` exactly once at end-of-pass, preserving the Salsa-ready
idempotence invariant (plan §C7). `Resolution::Unresolved` now carries
the case-folded `name: OxablAtom` so lint diagnostics don't reslice
the
source span per emission (plan §C5).
Schema integration: qualified `table.field` access reports
`Unresolved { NoSchema }` when schema isn't loaded; with a buffer in
scope and schema loaded, the field reference surfaces as `External`
pending Phase 4b's schema-backed field lookup wiring.
`analyze_file` now runs both declare and resolve, so the `Semantic`
struct ships with populated `references` and (signature) `types` side
tables for the first time.
Tests: 50 inline unit tests covering bare-identifier scope walking,
shadowing (variable > buffer, variable > builtin), function calls with
recursed arguments, `NEW` class resolution, `CAN-FIND` buffer lookup,
field access with/without schema, `ASSIGN` read+write counts, `RUN`
OUTPUT/INPUT-OUTPUT counting, `MESSAGE SET`, statement-level buffer
references, `FOR EACH` implicit buffer, control-flow walks, trigger
block bodies, built-in visibility through nested scopes, class-type
upgrades, and idempotence under repeated `resolve_pass` runs.
Third pass of the v1 semantic layer. Walks every expression and synthesizes a `ResolvedType` into `types[expr.id]` via bottom-up type synthesis. `analyze_file` now runs all three passes (declare → resolve → check) end-to-end. New modules: - `coercion.rs` — `assignable` / `assignable_strict` / `is_narrowing_warning` / `widen_primitive`. Widening ladders (Integer→Int64→Decimal, Date→Datetime→DatetimeTz, Character→Longchar). Silent numeric narrowing. Longchar→Character, Datetime→Date, DatetimeTz→Date flagged as warnings. `Unknown` is universal bottom; `Error` poisons without cascade. - `operators.rs` — binary/unary typing tables. `/` always returns `Decimal` (ABL quirk). `DATE + INTEGER → DATE` (days), `DATETIME + INTEGER → DATETIME` (ms) preserve date-like type. `Date - Date → Integer`, `Datetime - Datetime → Int64`. Comparisons → `Logical` iff operands share a widening ladder, else `Error`. `AND`/`OR` need `Logical`; `BEGINS`/`MATCHES`/`CONTAINS` need character-family operands. - `check.rs` — `check_pass` walker. Class/Interface symbols resolve to `Class(SymbolId)` so `NEW Foo(...)` has an instance type. Buffer / TempTable symbols resolve to `Buffer(SymbolId)`. Integer literals outside i32 range synthesize as `Int64`. Ternary widens branches; Unknown absorbs to the other branch. Emits no diagnostics — LINT0004 reads the populated `types` side table. Tests: 79 new unit tests (20 coercion, 24 operator, 35 end-to-end integration). Workspace total: 163 → 895 passing, all green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.