Implement RFC 0028: make untyped R functions callable - #30
Merged
fabriceHategekimana merged 1 commit intoSep 12, 2026
Merged
Conversation
`Lang::RFunction` (`function(a, b) { ... }`) now types as a real
`(Any, ..., Any) -> Any` function with n parameters, instead of the
0-ary `Type::UnknownFunction` placeholder that made any call with
arguments a type error. `Type::UnknownFunction` (used for preloaded
untyped base-R builtins like `Position`, `t`, `Reduce`) becomes
variadic for the same reason — fixing only `RFunction` would leave
the bug reachable through every untyped base-R name.
- `processes/type_checking/mod.rs`: `Lang::RFunction`'s typing rule
builds a `Type::Function` with n `Any` params -> `Any`.
- `components/type/mod.rs` and `components/type/function_type.rs`:
`Type::UnknownFunction`'s conversion to `FunctionType` is now a
single variadic `Any` parameter -> `Any`.
- `components/error_message/type_error.rs`: new `TypeError::
UntypedFunctionArity` (T044) replaces the confusing "no signature
matches () -> UnknownFunction" message with the RFC's proposed
wording when an untyped function is called with the wrong arity.
- `processes/type_checking/function_application.rs`: wires the new
error in, using `FunctionType::is_r_function()` to detect the
untyped-function shape.
- `cases/0062-0064`: regression cases for the callable case, the
arity error message, and the preloaded-builtin case.
Bumps the `guard_any_type_call_count_is_tracked` baseline 19 -> 21:
two new `any_type()` calls in the `RFunction` typing arm, which is
the RFC's whole point, not a silent degradation.
Tracking issue: #29
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ETPqhgWqDMt7UaUQXdxJmN
fabriceHategekimana
deleted the
implement-rfc-0028-untyped-r-functions
branch
September 12, 2026 07:45
5 tasks
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.
Summary
Implements the accepted RFC 0028 (tracking: #29): an untyped R function (
function(a, b) { ... }) becomes callable, checked on arity only, with its result typedAny.Lang::RFunctionnow types as a real(Any, ..., Any) -> Anyfunction withnparameters (parameters.len()), instead of the 0-aryType::UnknownFunctionplaceholder that rejected any call with arguments.Type::UnknownFunction(preloaded untyped base-R builtins —Position,t,Reduce, …) becomes variadic for the same reason: fixing onlyRFunctionwould leave the same bug reachable through every untyped base-R name (the RFC calls this "the load-bearing half").TypeError::UntypedFunctionArity(T044) replaces the old confusingNo signature of function 'x' matches this call ... () -> UnknownFunctionmessage with the RFC's proposed wording when an untyped call's arity is wrong:cases/0062'sR/main.Rrule.cases/entries per the RFC's implementation checklist: the callable case, the arity error message, and the preloaded-builtin case.Test plan
cargo test --workspace— 869 tests pass (0 failures)typr case run— 47 PASS, 0 REGRESS (3 new cases added, all PASS)docs/philosophy/intro.md'smy_addition) now compilesPosition(1, 2)now compilesmy_addition(num1, num2) |> as.Integer())Not in scope here (left for follow-up, per the RFC checklist):
syntaxe.mdand thetypr.github.iodocumentation update (docs/philosophy/intro.md'snoplaygroundremoval) — no syntax changed, and the docs live in a separate repo.🤖 Generated with Claude Code
https://claude.ai/code/session_01ETPqhgWqDMt7UaUQXdxJmN