Open Divesh-Otwani opened 1 year ago
Reduced example (note, that I have annotated should-fail
s type):
(module m G (defcap G () true)
(defun helper:string (x:integer y:string) (format "{} of {}" [x y]))
(defun should-fail: string (x:integer)
(helper x)))
(typecheck 'm)
Output:
"Loaded module m, hash 9rbppHYjW2Q9uDnjtsfdfxIvTxyy9qxtYOVbRX-MGMk"
"Typecheck m: success"
Reduced example (note, that I have annotated
should-fail
s type):(module m G (defcap G () true) (defun helper:string (x:integer y:string) (format "{} of {}" [x y])) (defun should-fail: string (x:integer) (helper x))) (typecheck 'm)
Output:
"Loaded module m, hash 9rbppHYjW2Q9uDnjtsfdfxIvTxyy9qxtYOVbRX-MGMk" "Typecheck m: success"
Ah ... so it doesn't depend on using another module. I thought it did because that's the only place I noticed it in my pact work. Here's the repl version:
(begin-tx)
(module m G (defcap G () true)
(defun helper:string (x:integer y:string) (format "{} of {}" [x y]))
(defun should-fail: string (x:integer)
(helper x)))
(typecheck "m")
(print (expect-failure "wrong arg count" (m.should-fail 3)))
(commit-tx)
This seems to point to a discrepancy in the runtime tc vs the static tc. The expression (helper x)
doesn't seem to track saturation in the static tc, just the type of the thing it's "supposed" to return via the type of the body, as evidenced by:
pact> (m.helper 3)
<interactive>:0:0:Error: helper: Incorrect number of arguments (1) supplied; expected 2
@jmcardon is going to get started reworking the typechecker, but I'll see if i can't track down the problem when I get back.
Issue description
If I call a function in an external module with the wrong number of arguments, this won't be detected by the typechecker.
Steps to reproduce
bad-typecheck.pact
helper.pact
bad-typecheck.repl
Expected Behavior
The line
(typecheck "free.bad-typecheck")
should display the error that we callhelper
with the wrong number of arguments.