8000 Blocks can't ignore unused parameters — every position must be explicitly bound, even with |_| · Issue #354 · kexhq/kex · GitHub
[go: up one dir, main page]

Skip to content

Blocks can't ignore unused parameters — every position must be explicitly bound, even with |_| #354

Closed

Description

@akoskovacs

A block passed where a function of one argument is expected must declare exactly that argument, even when the block never uses it — there is no way to write a zero-parameter block and have Kex treat it as "ignore whatever you're given." |_| (or a named-but-unused binding) is required everywhere, with no exceptions found so far.

Repro

Three different stdlib/application shapes, same failure:

[1, 2, 3].each do
  IO.printLine("tick")
end
# error: `each` expects argument 2 to be A -> Void, but got () -> Void
3.times do
  IO.printLine("hi")
end
# error: `times` expects argument 2 to be Integer -> Void, but got () -> Void
# Rodolfo (kexhq/rodolfo): a route handler ignoring the request context
get "/" do
  "Hello from Kex!"
end
# error: `get` expects argument 2 to be Context -> Reply, but got () -> String

All three work fine with an explicit discard: .each do |_| ... end, .times do |_| ... end, get "/" do |_| ... end.

Why it matters

Integer#times is the clearest case: the index is routinely irrelevant ("do this 3 times") and every other block-taking API where the argument is commonly unused — an HTTP route that ignores the request, a timer tick, a retry callback — hits the same friction. I looked at working around this at the call-site library level (overloading a function to accept either A -> B or () -> B) rather than filing this; it didn't work cleanly either — the two overloads didn't resolve/unify the way I expected, so it doesn't look like something callers can reasonably paper over themselves.

Expected

A block with fewer parameters than the expected function type should be accepted, with the missing arguments simply discarded — the way |_| already behaves, just without requiring the explicit no-op parameter for every unused position.

Environment

kex 0.4.0-beta.3, 293a0b5 — locally built dev toolchain. Found while building kexhq/rodolfo's route handlers and documentation examples.

Activity

  1. added this to the 0.4.0 milestone on Sep 15, 2026
  2. added a commit that references this issue on Sep 15, 2026
  3. added 2 commits that reference this issue on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingImportantNeeds attention sooner rather than laterTypechecker

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0