Public repository: timo / feel

Reader

An interpreter of FEEL, written in Rust, with integrations for PostgreSQL, WASM, Lua, and Python.

docs: ADR-47 — variable-position run starts, registry probe, inner-scope gap

draft feat/special-char-names

docs: ADR-47 — variable-position run starts, registry probe, inner-scope gap

Records the review follow-ups: runs never start at a path member or a
structure keyword; the wrappers probe `ScopeWithFunctions`; new deviation
"names in inner scopes" (path members, filter-element keys — root-only
probe) with workaround; error-order note for the one-shot wrappers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Changesete63ca90ddf2b483a516e41c3cc51d25014fe2239
Author (claimed)Timo Stolz <timo.stolz@gmail.com>,
Parentsa934aced1a8f
Children
Pushlog
by timo via ssh

modified DECISIONS.md +20 −3

@@ -2277,7 +2277,10 @@
22772277
      `Expr::Var` resolution exactly — a context binding or a built-in name — because parse
22782278
      and eval must agree on what "in scope" means. Since ADR-21/RD-11 every wrapper already
22792279
      materializes exactly the root level into `Context` and traverses the rest lazily, the
2280
-     oracle needs no new input traversal and no laziness regression.
2280
+     oracle needs no new input traversal and no laziness regression. A call head also
2281
+     resolves against the ambient host-function registry (ADR-23, `eval_call` step 3), so
2282
+     the wrappers' one-shot `evaluate` probes `ScopeWithFunctions { context, functions }`
2283
+     — a hyphen-named host function (`my-fn(1)`) is callable.
22812284
   2. **Lexer pass 2.5** — `fuse_special_names` runs *after* `join_names` (so a multi-word part
22822285
      like `total price` is already one word unit — `total price-total` is reachable) and before
22832286
      `mark_reverse_open` (a fused `Name` completes a value for the `]`-role classifier). It
@@ -2289,7 +2292,12 @@
22892292
      the subtraction the TCK expects), and after a miss it resumes *inside* the run
22902293
      (`a-b-c` with only `b-c` bound parses as `a - b-c`). Multi-char operators (`..`, `...`,
22912294
      `**`, `->`) are not name symbols, so ranges, descendants and exponents never fuse.
2292
-     Without a probe the pass is a no-op.
2295
+     A run only *starts* in a variable position: never at a word directly after an unfused
2296
+     `.` (a path member resolves against the navigated structure, not the root scope — a
2297
+     root key `y-z` must not turn `x.y-z` into `x.(y-z)`; it stays `(x.y) - z`), and never
2298
+     at a pure structure keyword (`return`, `in`, `then`, `else`, `satisfies`, `and`, `or`,
2299
+     `between` — `return -i` yields no `return-i` candidate); such keywords stay legal as
2300
+     *later* run words (`x-in`). Without a probe the pass is a no-op.
22932301
   3. **API policy** — `compile_with_probe(expr, probe)` and probe-aware one-shot `evaluate`
22942302
      (the context is the scope) in feel-core and every wrapper; `compile()` and the
22952303
      `CompiledExpr` classes stay **probe-free** — a compiled program must not pin one scope,
@@ -2324,12 +2332,21 @@
23242332
     `a and b` / `for x in y` scope-dependent — the sound cache guard would then disable
23252333
     feel-pg's parse cache for nearly every nontrivial expression. The engine keeps Tier 1/2
23262334
     (unconditional joins) as documented scope-blindness and defers the gated form.
2335
+  - *Names in inner scopes* are not probed: the oracle sees only the root level, so a
2336
+    special-character key one level down — a path member (`applicant.first-name`), a filter
2337
+    element's key (`items[unit-price > 10]`), a `for`/quantifier variable's or a context
2338
+    literal's own entries — keeps its arithmetic reading (`applicant.first - name`). Probing
2339
+    them would need the parser to know the *shape* of the navigated value, i.e. eval-time
2340
+    information at parse time. Workaround: a root-level alias, or `get value(applicant,
2341
+    "first-name")`.
23272342
   - *`?` and non-XID name starts* (rule 28, `what if?`) stay deferred with the 0083-feel-unicode
23282343
     widening.
23292344
 
23302345
 - **Consequence:** `a-b`, `Date-Time`, `x.y` and `if-then` resolve per §10.3.1.6 in the
23312346
   one-shot paths of feel-core/feel-py/feel-wasm/feel-lua and per row in feel-pg; `compile`
2332
-  remains the deterministic parse-once contract. Fixture suite 3145 → 3153 cases / 110 → 111
2347
+  remains the deterministic parse-once contract. The wrappers' one-shot `evaluate` now
2348
+  converts the context (and registry) *before* parsing, so when both the context and the
2349
+  expression are invalid, the context error is the one reported. Fixture suite 3145 → 3153 cases / 110 → 111
23332350
   files (the hand-written 0007-date-time-names fixture). Tests added: feel-core (6 test fns:
23342351
   scope resolution, longest-match/left-to-right incl. the TCK subtraction and `(a)-(b)`
23352352
   escape, name-vs-path/member interplay, probe-free-compile policy + both flags/candidates,

modified README.md +3 −1

@@ -75,7 +75,9 @@
7575
   vs the ~479 KB offset-only default, where a named zone evaluates to null).
7676
 
7777
 Still out of scope: unary tests (the non-interval `in` forms), names in
78
-*declaration* slots (`for a-b in …`, formal parameters, context keys) and
78
+*declaration* slots (`for a-b in …`, formal parameters, context keys),
79
+special-character names in *inner* scopes (path members like
80
+`applicant.first-name`, filter-element keys — only root-level names are probed),
7981
 space-joined reserved-word names (`Profit and loss`) and `?`/non-XID name
8082
 starts (`what if?`, grammar rule 28 — see ADR-47's deviations), typed
8183
 function parameters, and general invocation on an arbitrary