Skip to content

Commit 6267d9a

Browse files
committed
FIX: letting FORALL to reset position, when make it through normally, but not on BREAK/THROW/ERROR
So it is compatible with current Rebol2 and Red. Not like [my previous attempt](0612b72) Where I was considering the [older Rebol2 behavior](http://www.rebol.com/docs/words/wforall.html), which is no longer valid in Rebol 2.7.8 and Red. Related issue: metaeducation/rebol-issues#2331
1 parent 0612b72 commit 6267d9a

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/core/n-loop.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
if (THROWN(ds)) { // Break, throw, continue, error.
256256
if (Check_Error(ds) >= 0) {
257257
*DS_RETURN = *DS_NEXT;
258-
break;
258+
return R_RET; // does not resets series position
259259
}
260260
}
261261
*DS_RETURN = *ds;
@@ -267,7 +267,9 @@
267267
}
268268
else Trap_Arg(var);
269269

270-
*D_RET = *var;
270+
// !!!!! ???? allowed to write VAR????
271+
*var = *DS_ARG(1);
272+
//*D_RET = *var;
271273
return R_RET;
272274
}
273275

src/mezz/base-funcs.r

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ cause-error: func [
101101
change/only args spec-of first args
102102
]
103103
]
104-
args: head args
105104
; Build and throw the error:
106105
do make error! [
107106
type: err-type

src/tests/units/series-test.r3

+6-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,12 @@ Rebol [
116116
;-- compatible with R2 & Red - the series is at its tail
117117
data: [1 2 3 4]
118118
--assert unset? forall data []
119-
--assert tail? data
119+
--assert data = [1 2 3 4]
120+
data: next data
121+
--assert unset? forall data []
122+
--assert data = [2 3 4]
123+
--assert 4 = forall data [data/1]
124+
--assert data = [2 3 4]
120125

121126
;@@ https://github.com/rebol/rebol-issues/issues/2331
122127
--test-- "Escaping from FORALL loop using THROW"

0 commit comments

Comments
 (0)