Skip to content

type-parameterized functions not specialized when passed as argument #633

@jruderman

Description

@jruderman

Ran into this while trying to make an ivec_equal function. Here's a testcase without any vectors.

fn builtin_equal_int(&int a, &int b) -> bool {
    ret a == b;
}

fn builtin_equal[T](&T a, &T b) -> bool {
    ret a == b;
}

fn apply_equal[T](fn (&T, &T) -> bool f, &T a, &T b) -> bool {
    ret f(a, b);
}

fn main() {
    assert  builtin_equal_int(5, 5);
    assert  builtin_equal(5, 5);
    assert  apply_equal(builtin_equal_int, 5, 5);
    assert  apply_equal(builtin_equal, 5, 5); // CRASH
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions