Public repository: timo / feel

Reader

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

docs: ADR-38 + ROADMAP/README — value-invocation of non-functions (1131)

public

docs: ADR-38 + ROADMAP/README — value-invocation of non-functions (1131)

ADR-38 documents the Expr::Invoke variant, Invocable grammar nonterminal,
eval dispatch, ingester change, and why case 001 is hand-written.

ROADMAP marks the non-function invocation item shipped (ADR-38) and
clarifies that invoking an expression that holds a function (var(args),
lib.fn(args)) remains deferred.

README refines the "Still out of scope" sentence to note that invoking a
non-function literal is now handled (yields null per spec).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Changeset828141660cd723169ff9bade5c806ef7bb4cc550
Author (claimed)Timo Stolz <timo.stolz@gmail.com>,
Parents945b69481569
Children
Pushlog
by timo via ssh

modified DECISIONS.md +43 −0

@@ -1792,3 +1792,46 @@
17921792
   - **Ingester:** `"sort"` added to `_BUILTINS`. `fits_slice_grammar` gains a function-literal extraction step before the free-name scan: `\bfunction\s*\(bare_params\)` patterns are found, param names collected into `fn_params` (added to `allowed`), and the head blanked from `scan`. Only untyped bare-identifier param lists match; a `:` annotation keeps the expression outside auto-ingest.
17931793
 - **Tests:** `sort_ascending_descending`, `sort_by_context_field`, `sort_stable`, `sort_named_args`, `sort_as_first_class_builtin`, `sort_error_cases`, `sort_higher_order_closure_over_input`, `list_replace_matching_form`, `list_replace_matching_named_args`, `list_replace_matching_error_cases` in `lib.rs` `function_tests`.
17941794
 - **Consequence:** Resolves the `sort`/`list replace` matching-form deferrals at ADR-15 (L331), ADR-24 (L779), the roadmap "Smaller deferrals" note, and ADR-36 (L1761). **Suite 2896 → 2907.**
1795
+
1796
+## ADR-38: Value-invocation of a literal callee (DMN §10.3.2.13.2)
1797
+
1798
+- **Context:** `1131-feel-function-invocation` exercises the spec rule that *invoking
1799
+  a non-function yields null* (§10.3.2.13.2). All 8 decisions call a literal that is
1800
+  not a function — `null()`, `"some_func"()`, `"abs"(-1)`, `@"2023-11-11"()`,
1801
+  `123()`, `true()`, `false()`, and an unknown name `non_existing_function()`. The
1802
+  unknown-name case (001) already worked: `FnCall` dispatch returns `Value::Error`
1803
+  (→ null). Cases 002–008 did not parse: the grammar's only invocation form was
1804
+  `Name "(" … ")"` — a literal callee (`null(`, `123(`, `"abs"(`) was a syntax error.
1805
+  The suite was never ingested; `null()` sat in `OUT_OF_SCOPE_EXPR_SKIPS` with an
1806
+  ADR-23 note. The fix requires a separate AST node to keep named dispatch (`FnCall`)
1807
+  on its unchanged path — routing a `Name` through value-evaluation would break every
1808
+  builtin call because builtins are not scope-bound `Value::Function` values.
1809
+- **Decision:**
1810
+  - **`ast.rs`:** New `Expr::Invoke(Box<Expr>, CallArgs)` variant. Semantics: evaluate
1811
+    the callee expression; invoke if it is a `Value::Function`, otherwise error-null
1812
+    (→ null at the lenient boundary). `is_clock_free` gets a matching arm that treats
1813
+    `Invoke` like `FnCall` without the `now`/`today` guard (a literal callee is never
1814
+    a clock read).
1815
+  - **`feel.lalrpop`:** New `Invocable` nonterminal for the six literal forms (`Num`,
1816
+    `Str`, `TemporalLit`, `"true"`, `"false"`, `"null"`). `Name` is deliberately
1817
+    absent. Two productions in `Postfix`: `<e:Invocable> "(" ")" => Invoke(…)` and
1818
+    `<e:Invocable> "(" <a:Comma<Arg>> ")" => Invoke(…)`. `NbPostfix` and `EpPostfix`
1819
+    (interval-endpoint / in-RHS clones) are not extended — 1131 expressions are
1820
+    top-level. LALRPOP's no-conflict build gate validates LR(1)-cleanliness.
1821
+  - **`eval.rs`:** `Expr::Invoke` arm evaluates the callee with `.forced()`, dispatches
1822
+    to `invoke` for `Value::Function`, returns `Value::Error` for everything else.
1823
+    Reuses the existing `eval_args` / `invoke` helpers unchanged.
1824
+  - **Ingester:** `OUT_OF_SCOPE_EXPR_SKIPS` entry for `1131:002:decision002` removed.
1825
+    Case 001 (`non_existing_function()`) remains outside auto-ingest: `fits_slice_grammar`
1826
+    cannot distinguish a *deliberately* unknown name from a missing input name. It is
1827
+    hand-written into the fixture (same practice as `0092-feel-lambda` cases 017/018,
1828
+    ADR-37).
1829
+- **Tests:** `invoke_non_function_yields_null` in `lib.rs::function_tests` asserts all
1830
+  eight 1131 shapes → null, plus a regression check that `abs(-1)` / `abs(n: -2)` still
1831
+  route through `FnCall`. All 8 cases covered by `tck_fixtures_pass` via the ingested
1832
+  fixture.
1833
+- **Consequence:** Resolves the "General invocation → non-function" item in the ROADMAP
1834
+  "Smaller, independent deferrals" section. Invoking an arbitrary *expression that holds
1835
+  a function* (`var(args)`, `lib.fn(args)`) remains deferred (would require widening
1836
+  `Invocable` to `Postfix`, reintroducing the `Name`-vs-`Var` ambiguity). **Suite
1837
+  2907 → 2915.**

modified README.md +2 −1

@@ -68,7 +68,8 @@
6868
 
6969
 Still out of scope: unary tests (the non-interval `in` forms), special characters
7070
 in names, typed function parameters, and general invocation on an arbitrary
71
-expression (`expr(args)`, imported `lib.fn(args)`). See [DECISIONS.md](DECISIONS.md) for the
71
+expression that *holds* a function (`var(args)`, imported `lib.fn(args)`) — invoking
72
+a non-function literal yields null per spec (ADR-38). See [DECISIONS.md](DECISIONS.md) for the
7273
 architecture decisions, the deferred-scope roadmap, and accepted deviations
7374
 (notably: numbers are `f64`, not spec `decimal128`; type errors evaluate to
7475
 `null`; temporal values outside jiff's range are skipped) — plus the

modified ROADMAP.md +7 −3

@@ -241,9 +241,13 @@
241241
 
242242
 ## Smaller, independent deferrals
243243
 
244
-- **General invocation** `expr(args)` / `lib.fn(args)` (e.g. `null()` in
245
-  `1131-feel-function-invocation`) — invoking an arbitrary expression, not just a
246
-  named function. Out of slice (ADR-23).
244
+- **General invocation of a non-function → null** ✅ **shipped (ADR-38).**
245
+  Literal callees (`null()`, `123()`, `"abs"(-1)`, `@"date"()`, `true()`, `false()`)
246
+  and unknown names (`non_existing_function()`) all yield null per DMN §10.3.2.13.2.
247
+  Full `1131-feel-function-invocation` suite now passes (8/8).
248
+  Still deferred: invoking an arbitrary *expression* that holds a function —
249
+  `var(args)` or `lib.fn(args)` — would require widening the grammar beyond literal
250
+  callees and reintroduces the `Name`-vs-`Var` dispatch ambiguity.
247251
 - **Emoji / non-XID names** as bare context keys (`{🐎: "bar"}`,
248252
   `0083-feel-unicode`) — the lexer accepts XID identifiers only; 2 cases skipped
249253
   (`NON_XID_NAME_SKIPS`).