| @@ -1792,3 +1792,46 @@ |
| 1792 | 1792 | - **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. |
| 1793 | 1793 | - **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`. |
| 1794 | 1794 | - **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.** |