Skip to content

Commit

Permalink
ATRONIX: Type-check call of TRY/except handler
Browse files Browse the repository at this point in the history
TRY/except now checks that the typespec of a handler function actually
allows calls with the error value, before calling the handler function.

This fixes CureCode issue #1514.

metaeducation/rebol-issues#1514
  • Loading branch information
Oldes committed Jun 8, 2018
1 parent bf34bb5 commit 7e61a4a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/core/n-control.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,14 @@ enum {
}
else { // do func[err] error
REBVAL error = *DS_NEXT; // will get overwritten
REBVAL *args = BLK_SKIP(VAL_FUNC_ARGS(&handler), 1);
if (NOT_END(args) && !TYPE_CHECK(args, VAL_TYPE(&error))) {
// TODO: This results in an error message such as "action!
// does not allow error! for its value1 argument". A better
// message would be more like "except handler does not
// allow error! for its value1 argument."
Trap3(RE_EXPECT_ARG, Of_Type(&handler), args, Of_Type(&error));
}
Apply_Func(0, &handler, &error, 0);
}
}
Expand Down

1 comment on commit 7e61a4a

@Oldes
Copy link
Owner Author

@Oldes Oldes commented on 7e61a4a Jun 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally from this PR: rebol#227

Please sign in to comment.