Skip to content

Commit

Permalink
FIX: letting FORALL to reset position, when make it through normally,…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
Oldes committed Dec 5, 2018
1 parent 0612b72 commit 6267d9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/core/n-loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
if (THROWN(ds)) { // Break, throw, continue, error.
if (Check_Error(ds) >= 0) {
*DS_RETURN = *DS_NEXT;
break;
return R_RET; // does not resets series position
}
}
*DS_RETURN = *ds;
Expand All @@ -267,7 +267,9 @@
}
else Trap_Arg(var);

*D_RET = *var;
// !!!!! ???? allowed to write VAR????
*var = *DS_ARG(1);
//*D_RET = *var;
return R_RET;
}

Expand Down
1 change: 0 additions & 1 deletion src/mezz/base-funcs.r
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ cause-error: func [
change/only args spec-of first args
]
]
args: head args
; Build and throw the error:
do make error! [
type: err-type
Expand Down
7 changes: 6 additions & 1 deletion src/tests/units/series-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ Rebol [
;-- compatible with R2 & Red - the series is at its tail
data: [1 2 3 4]
--assert unset? forall data []
--assert tail? data
--assert data = [1 2 3 4]
data: next data
--assert unset? forall data []
--assert data = [2 3 4]
--assert 4 = forall data [data/1]
--assert data = [2 3 4]

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

0 comments on commit 6267d9a

Please sign in to comment.