Skip to content

Commit 1150994

Browse files
committed
FIX: fixed regression with break in a reduce block
related to: Oldes/Rebol-issues#1760 related to: Oldes/Rebol-issues#2060
1 parent 249f1be commit 1150994

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/core/n-control.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ enum {
9090
{
9191
if (ANY_SERIES(value) || IS_MAP(value) || IS_BITSET(value))
9292
Protect_Series(value, flags);
93-
else if (IS_OBJECT(value) || IS_MODULE(value))
93+
else if (ANY_OBJECT(value))
9494
Protect_Object(value, flags);
9595
}
9696

@@ -741,8 +741,9 @@ enum {
741741
{
742742
REBVAL *val = D_ARG(1);
743743
REBVAL *into = D_REF(5) ? D_ARG(6) : 0;
744+
REBCNT type = VAL_TYPE(val);
744745

745-
if (IS_BLOCK(val) || IS_PAREN(val)) {
746+
if (type == REB_BLOCK || type == REB_PAREN) {
746747
REBSER *ser = VAL_SERIES(val);
747748
REBCNT index = VAL_INDEX(val);
748749

@@ -753,9 +754,12 @@ enum {
753754
else
754755
Reduce_Block(ser, index, into);
755756

756-
if(!into)
757-
SET_TYPE(DS_TOP, VAL_TYPE(val));
758-
757+
if (type == REB_PAREN)
758+
// there must be also test, if the result is a block,
759+
// because it can be also THROWN! see issue-1760
760+
if (!into && IS_BLOCK(DS_TOP))
761+
SET_TYPE(DS_TOP, REB_PAREN);
762+
759763
return R_TOS;
760764
}
761765
else if (into != 0) {
@@ -809,12 +813,11 @@ enum {
809813
REBVAL *blk = VAL_BLK_DATA(D_ARG(2));
810814
REBVAL *result;
811815
REBOOL all = D_REF(5);
812-
REBOOL is_case = D_REF(6);
813816
REBOOL found = FALSE;
814817

815818
// Find value in case block...
816819
for (; NOT_END(blk); blk++) {
817-
if (!IS_BLOCK(blk) && 0 == Cmp_Value(DS_ARG(1), blk, is_case)) { // avoid stack move
820+
if (!IS_BLOCK(blk) && 0 == Cmp_Value(DS_ARG(1), blk, FALSE)) { // avoid stack move
818821
// Skip forward to block...
819822
for (; !IS_BLOCK(blk) && NOT_END(blk); blk++);
820823
if (IS_END(blk)) break;

src/tests/units/evaluation-test.r3

+3
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,9 @@ Rebol [
854854
--assert :a =? 1
855855
a: 1 loop 1 [a: compose [(break)]]
856856
--assert :a =? 1
857+
;@@ https://github.com/Oldes/Rebol-issues/issues/2060
858+
a: 1 loop 1 [a: reduce quote (break)]
859+
--assert :a =? 1
857860

858861
===end-group===
859862

0 commit comments

Comments
 (0)