Skip to content

Commit fb66246

Browse files
committed
FIX: crash when using do on a function which returns itself
resolves: Oldes/Rebol-issues#196 related to: Oldes/Rebol-issues#886 and Oldes/Rebol-issues#2440
1 parent d1ff72d commit fb66246

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/core/c-do.c

+1
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,7 @@ x*/ static REBINT Do_Args_Light(REBVAL *func, REBVAL *path, REBSER *block, REBCN
932932

933933
// The return value is a FUNC that needs to be re-evaluated.
934934
if (VAL_GET_OPT(DS_TOP, OPTS_REVAL) && ANY_FUNC(DS_TOP)) {
935+
VAL_CLR_OPT(DS_TOP, OPTS_REVAL); // avoid recursion https://github.com/Oldes/Rebol-issues/issues/196
935936
value = DS_POP; // WARNING: value is volatile on TOS1 !
936937
word = Get_Type_Word(VAL_TYPE(value));
937938
index--; // Backup block index to re-evaluate.

src/tests/units/func-test.r3

+5-3
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,11 @@ Rebol [
258258

259259
--test-- "issue-196"
260260
;@@ https://github.com/Oldes/Rebol-issues/issues/196
261-
; with change related to https://github.com/Oldes/Rebol-issues/issues/2440
262-
; bellow test is now throwing error instead of `true`
263-
--assert error? try [do func [a] [context? 'a] 1] ;-no crash
261+
;@@ https://github.com/Oldes/Rebol-issues/issues/886
262+
;@@ https://github.com/Oldes/Rebol-issues/issues/2440
263+
--assert function? do func [/local a] [context? 'a] ;-no crash
264+
--assert 1 = do has [arg] [1]
265+
--assert function? do has [arg] [context? 'arg] ;-no crash and recursion
264266

265267
--test-- "issue-216"
266268
;@@ https://github.com/Oldes/Rebol-issues/issues/216

0 commit comments

Comments
 (0)