Open DrRuhe opened 1 year ago
Hi, thank for reporting! I concur that this is not a rare error to make, and the message is not helping.
I currently don't have a good rationale to throw an error though, we'll have to think about it more. What happens is that a contract annotation like this ends up as something like with_error = SomeParametricContract label {}
, which is indeed still a function that is not serializable. The issue is that we can't just error out when a contract application evaluates to a function: typically, a function contract like f | Number -> String
turns into $arrow $number $string f
, and should evaluate to a function (a version of f
wrapped with additional checks).
Maybe we can backtrack on such a non-serializable error and check this case in an ad-hoc way (does the problematic value have a contract attached).
Another improvement, independently from this contract error, should be to show which field was being evaluated/serialized when the error occurred; that would at least give a minimum amount of error locality.
Describe the bug Given this Contract that takes a parameter the
non-serializable term
error will appear pointing to the definition of the contract, which is unrelated to the actual place where the contract is used incorrectly:Expected behavior Instead of throwing an unrelated
non-serializable term
error, the CLI should report something like this: