Skip to content

Commit 8429397

Browse files
committed
FIX: MAKE ERROR! does not process THROWN values as THROWN
resolves: Oldes/Rebol-issues#2244
1 parent c610ebd commit 8429397

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/core/c-error.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ static REBOL_STATE Top_State; // Boot var: holds error state during boot
356356
REBSER *err; // Error object
357357
ERROR_OBJ *error; // Error object values
358358
REBINT code = 0;
359+
REBVAL *tmp;
359360

360361
// Create a new error object from another object, including any non-standard fields:
361362
if (IS_ERROR(arg) || IS_OBJECT(arg)) {
@@ -380,8 +381,14 @@ static REBOL_STATE Top_State; // Boot var: holds error state during boot
380381
// If user set error code, use it to setup type and id fields.
381382
if (IS_BLOCK(arg)) {
382383
DISABLE_GC;
383-
Do_Bind_Block(err, arg); // GC-OK (disabled)
384+
tmp = Do_Bind_Block(err, arg); // GC-OK (disabled)
384385
ENABLE_GC;
386+
if (THROWN(tmp)) {
387+
*value = *tmp;
388+
return;
389+
}
390+
391+
385392
//It was possible to set error using code, but that's now ignored!
386393
//@@ https://github.com/Oldes/Rebol-issues/issues/1593
387394
//if (IS_INTEGER(&error->code) && VAL_INT64(&error->code)) {

src/tests/units/evaluation-test.r3

+5
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,11 @@ Rebol [
799799
--assert 1 = catch/all [a: 0 catch/name [++ a throw/name 1 'foo] 'bar a: a * 10]
800800
--assert 1 = a
801801

802+
--test-- "throw from make error!"
803+
;@@ https://github.com/Oldes/Rebol-issues/issues/2244
804+
--assert error? catch [make error! [type: 'Access arg1: 10 + 20 id: 'Protocol]]
805+
--assert 30 = catch [make error! [type: 'Access arg1: throw 10 + 20 id: 'Protocol]]
806+
802807
===end-group===
803808

804809

0 commit comments

Comments
 (0)