Skip to content

Commit 7e61a4a

Browse files
committed
ATRONIX: Type-check call of TRY/except handler
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
1 parent bf34bb5 commit 7e61a4a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/core/n-control.c

+8
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,14 @@ enum {
777777
}
778778
else { // do func[err] error
779779
REBVAL error = *DS_NEXT; // will get overwritten
780+
REBVAL *args = BLK_SKIP(VAL_FUNC_ARGS(&handler), 1);
781+
if (NOT_END(args) && !TYPE_CHECK(args, VAL_TYPE(&error))) {
782+
// TODO: This results in an error message such as "action!
783+
// does not allow error! for its value1 argument". A better
784+
// message would be more like "except handler does not
785+
// allow error! for its value1 argument."
786+
Trap3(RE_EXPECT_ARG, Of_Type(&handler), args, Of_Type(&error));
787+
}
780788
Apply_Func(0, &handler, &error, 0);
781789
}
782790
}

0 commit comments

Comments
 (0)