Skip to content

Feat/oxabl semantic phase4b#50

Merged
evanbrobertson merged 4 commits into
masterfrom
feat/oxabl-semantic-phase4b
May 1, 2026
Merged

Feat/oxabl semantic phase4b#50
evanbrobertson merged 4 commits into
masterfrom
feat/oxabl-semantic-phase4b

Conversation

@evanbrobertson
Copy link
Copy Markdown
Contributor

No description provided.

evanbrobertson and others added 4 commits April 17, 2026 23:01
…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>
@evanbrobertson evanbrobertson merged commit 79168a5 into master May 1, 2026
6 checks passed
@evanbrobertson evanbrobertson deleted the feat/oxabl-semantic-phase4b branch May 1, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant