Skip to content

A call through a &fn(A) -> R parameter runs nothing: read(s) where read: &fn(&str) -> str prints no output and no diagnostic (seed and origin/main) #1603

Closed

Description

@ehartford

Found while making src/compiler/ConanPatch.w conform to D63 (fn(A) -> R is not Copy).

fn apply(s: &str, read: &fn(&str) -> str) -> str: read(s)
fn shout(s: &str) -> str: s.clone() ++ "!"
fn main:
    var i = 0
    while i < 2:
        print(apply("a", &shout))
        i = i + 1

Expected a! twice. Actual: no output at all, exit 0, no diagnostic — on the pinned seed (nightly-20260922) and on a stage1 of origin/main 02301f8. The by-value form (read: fn(&str) -> str, apply("a", read)) prints correctly.

Either a call through a reference to a callable must auto-deref like every other &T use (§3.7), or the parameter type must be rejected; silently running nothing is neither. Not fixed in stack #1585 (ConanPatch uses a struct of callables passed by reference instead).

Activity

  1. ehartford commented on Sep 26, 2026

    @ehartford
    ContributorAuthor

    Fixed on main by #1701 (3d5dc47): capture-set completeness, stored-view refusal, calls through &fn; battery green and pinned by the tests named in the PR.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions