ajhahn.de
← Flash
Flash 27 lines
// REJECT probe — generic application arity is checked natively: in value
// position, in a parameter annotation, and at an application site earlier
// in the file than the declaration it names.

fn Box(comptime T type) type {
    return T
}

fn Pair(comptime A type, comptime B type) type {
    return struct {
        first A,
        second B,
    }
}

const Wrong = Box(u8, u8) // expect-error: generic 'Box' expects 1 argument, found 2

fn f(x Pair(u8)) void { // expect-error: generic 'Pair' expects 2 arguments, found 1
    _ = x
}

const Early = Late(u8, u8) // expect-error: generic 'Late' expects 1 argument, found 2

fn Late(comptime T type) type {
    return T
}