Skip to content

@typeOf() should take multiple parameters and do peer type resolution #439

Closed
@thejoshwolfe

Description

@thejoshwolfe

the type of:

const foo = switch (bar()) {
    A => a(),
    B => b(),
    C => c(),
}

is some type that each of a(), b(), and c() either are or can implicitly convert to. Determining this type is called peer type resolution. That's already a solved problem.

The @typeOf() builtin function should take multiple parameters and do peer type resolution on them to expose this concept directly to users.

This is useful in this context:

fn max(a: var, b: var) -> @typeOf(a, b) {
    if (a > b) a else b
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions