brownplt / pyret-lang

The Pyret language.
Other
1.07k stars 109 forks source link

Contracts on builtins #48

Open jpolitz opened 11 years ago

jpolitz commented 11 years ago

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 commented 11 years ago

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

blerner commented 11 years ago
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.
jpolitz commented 11 years ago

Thanks. Good band-aid.

schanzer commented 6 years ago

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

blerner commented 6 years ago

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

schanzer commented 4 years ago

@jpolitz is this still an issue?

blerner commented 4 years ago

Yes, it's still exposing an internal error.