Skip to content

Method not found when type checking Table stemming from incomplete set of methods in global provides #1693

Open
@robertDurst

Description

@robertDurst

Consider the following code:

tbl = table: name
  row: "Rob"
end

tbl.row("Foo")

When I execute without type checker all is well.
Screenshot 2023-06-13 at 12 45 32 AM

With type checker, .row is not found.
Screenshot 2023-06-13 at 12 45 45 AM

I did quite a bit of digging and printing and I noticed that the fields on the Table data-type obeject resulting from instantiate-data-type(obj-type, context) were surprisingly limited:

t-data(Table, [list: ], [list: ], [string-dict: length, ( -> Number)], builtin(dummy location))

I expect many more methods than just this on Table. Eventually I landed on the global provides and noticed this:

"Table": ["data", "Table", [], [], {
    "length": ["arrow", [], "Number"]
}],

I reproduced locally by modifying tests/type-check/good/table.arr, then added the type signature for row to the global provides and it passed the type checker.

I noticed String-Dict and Reactor both "provide" their own data-types. Should Table do the same?

60 seconds of ctrl-f made me realize just moving the data-type from global provides to table provides isn't as simple as it might seem... it seems it will require resolving some dependency/module loading. Wanted to confirm the desired behavior before venturing further :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions