Skip to content

Commit

Permalink
FIX: MAKE ERROR! does not process THROWN values as THROWN
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jun 21, 2023
1 parent c610ebd commit 8429397
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/core/c-error.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ static REBOL_STATE Top_State; // Boot var: holds error state during boot
REBSER *err; // Error object
ERROR_OBJ *error; // Error object values
REBINT code = 0;
REBVAL *tmp;

// Create a new error object from another object, including any non-standard fields:
if (IS_ERROR(arg) || IS_OBJECT(arg)) {
Expand All @@ -380,8 +381,14 @@ static REBOL_STATE Top_State; // Boot var: holds error state during boot
// If user set error code, use it to setup type and id fields.
if (IS_BLOCK(arg)) {
DISABLE_GC;
Do_Bind_Block(err, arg); // GC-OK (disabled)
tmp = Do_Bind_Block(err, arg); // GC-OK (disabled)
ENABLE_GC;
if (THROWN(tmp)) {
*value = *tmp;
return;
}


//It was possible to set error using code, but that's now ignored!
//@@ https://github.com/Oldes/Rebol-issues/issues/1593
//if (IS_INTEGER(&error->code) && VAL_INT64(&error->code)) {
Expand Down
5 changes: 5 additions & 0 deletions src/tests/units/evaluation-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,11 @@ Rebol [
--assert 1 = catch/all [a: 0 catch/name [++ a throw/name 1 'foo] 'bar a: a * 10]
--assert 1 = a

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

===end-group===


Expand Down

0 comments on commit 8429397

Please sign in to comment.