Skip to content

Higher-order generic functions disobey kind system #1037

Closed

Description

@brson
fn spawn2<@T>(x: T, f: fn(T))  {
    f(x);
}

fn main() {
    fn foo<~T>(x: T) {
        log_err x;
    }

    spawn2::<@int>(@10, foo);
}

spawn2 is passing a shared kind to a function that only takes unique kinds.

Activity

  1. brson commented on Oct 13, 2011

    @brson
    ContributorAuthor

    There are probably similar issues with other generic types.

  2. ghost assigned on Nov 15, 2011
  3. marijnh commented on Nov 18, 2011

    @marijnh
    Contributor

    The restriction on taking the value of generics is currently making this impossible to reproduce.

    But even ignoring that, and updating the example to the new terminology, the current kind checker would catch that foo is being instantiated with a type that it doesn't accept. Closing (by #1177)

  4. added 2 commits that reference this issue on Aug 21, 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions