Skip to content
This repository
Browse code

Better (albeit not perfect) exception for badarity invocation of anon…

…ymous function.
  • Loading branch information...
commit 2a0da3fee05f2844b817983ded2ba1729f4b9a45 1 parent 1f07d38
Kresten Krab Thorup krestenkrab authored

Showing 1 changed file with 8 additions and 2 deletions. Show diff stats Hide diff stats

  1. +8 2 src/main/java/erjang/ERT.java
10 src/main/java/erjang/ERT.java
@@ -342,8 +342,13 @@ public static String describe_exception(Throwable e) {
342 342 }
343 343
344 344 public static void test_fun(EObject orig, EFun fun) {
345   - if (fun == null)
346   - throw new ErlangError(am_badfun, orig);
  345 + if (fun == null) {
  346 + if ((orig.testFunction()) != null) {
  347 + throw new ErlangError(new ETuple2(am_badarity, new ETuple2(orig, NIL)));
  348 + } else {
  349 + throw new ErlangError(am_badfun, orig);
  350 + }
  351 + }
347 352 }
348 353
349 354 static EInteger max_send_time = ERT.box(4294967295L);
@@ -779,6 +784,7 @@ public static EObject try_case_end(EObject val) {
779 784 public static EAtom am_attributes = EAtom.intern("attributes");
780 785 public static EAtom am_exports = EAtom.intern("exports");
781 786 public static EAtom am_badfun = EAtom.intern("badfun");
  787 + public static EAtom am_badarity = EAtom.intern("badarity");
782 788
783 789 public static EAtom am_name = EAtom.intern("name");
784 790 public static EAtom am_arity = EAtom.intern("arity");

0 comments on commit 2a0da3f

Please sign in to comment.
Something went wrong with that request. Please try again.