Skip to content

Figure out function types and subtyping story #45

@polybuildr

Description

@polybuildr

Currently, balloon naively treats all functions' types as equal. However, when checking function calls, since it traces the actual call, it points out incorrect number of arguments (which must match exactly, unlike JS or PHP).

So, in

fn call(g, x) {
    g(x);
}

call(fn () {}, 1);

you get

in test.bl, line 5, col 1:
issue in function call:
5 | call(fn () {}, 1);
    ^^^^^^^^^^^^^^^^^
in function in test.bl, line 2, col 5:
arguments mismatch: function `g` called with incorrect number of arguments
2 |     g(x);
        ^^^^

We need to figure out if accepting less or more arguments is part of subtyping. This could matter in cases like callbacks.

After this, we should make function types account for arity as well as return types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions