pact icon indicating copy to clipboard operation
pact copied to clipboard

Inability to take first-class table value as argument

Open bts opened this issue 6 years ago • 1 comments

@slpopejoy

With the following setup, and the module typechecking:

(begin-tx)
(env-data { "kadmin": { "keys": ["admin"], "pred": "=" } })
(env-keys ["admin"])
(define-keyset 'kadmin)
(module m1 'kadmin
  (defschema s i:integer)
  (deftable  tab:{s})
  (defun consume (t:table)
    t)
  (defun produce:table ()
    tab)
  )
(create-table tab)
(commit-tx)

(use m1)
(typecheck 'm1)
;"Typecheck m1: success"

We can return a first-class table from a function:

(produce)
;(TTable m1.tab:(TSchema m1.s [i:integer] Meta {_mDocs = Nothing, _mModel = []}) Meta {_mDocs = Nothing, _mModel = []})

But we can't pass a first-class table to a function that consumes one:

(consume (produce))
;tests/pact/table.repl:29:14: Type error: expected table, found table:(TSchema m1.s [i:integer] Meta {_mDocs = Nothing, _mModel = []})

bts avatar Feb 06 '19 18:02 bts

Related: #540

sirlensalot avatar Oct 31 '19 17:10 sirlensalot