pyret-lang icon indicating copy to clipboard operation
pyret-lang copied to clipboard

Contracts on builtins

Open jpolitz opened this issue 12 years ago • 7 comments

Many builltins, like _divide and substring, are partial, and give contract errors for erroneous inputs. We should turn these errors into meaningful Pyret errors somehow, and avoid paying to much to do so (that's the hard part).

jpolitz avatar Jul 16 '13 19:07 jpolitz

Another problem along these lines --- "hello".tonumber() yields a number value that contains #f, because of inadequate checking on the result.

jpolitz avatar Jul 29 '13 20:07 jpolitz

For now, I've committed 9a0803e, which changes tonumber to return
either a real number or nothing, rather than try to catch an
error...On 7/29/2013 4:05 PM, Joe Politz wrote:

  Another problem along these lines --- "hello".tonumber()
    yields a number value that contains #f, because of
    inadequate checking on the result.
  —
    Reply to this email directly or view
      it on GitHub.

blerner avatar Jul 29 '13 20:07 blerner

Thanks. Good band-aid.

jpolitz avatar Jul 29 '13 20:07 jpolitz

_divide(1,"2") seems to give Pyret-esque errors now, no?

schanzer avatar Nov 04 '17 02:11 schanzer

When I try it, I get an internal error (field not found "left" on an s-program). @jswrenn over to you...

blerner avatar Nov 04 '17 02:11 blerner

@jpolitz is this still an issue?

schanzer avatar Mar 17 '20 03:03 schanzer

Yes, it's still exposing an internal error.

blerner avatar Aug 13 '20 03:08 blerner