From 2d91e515d3d88c19d912a5d8e7a1636029012875 Mon Sep 17 00:00:00 2001 From: Oldes Date: Mon, 4 Jul 2022 17:56:51 +0200 Subject: [PATCH] CHANGE: `do path!` behavior made compatible with Rebol2 and Red resolves: https://github.com/Oldes/Rebol-issues/issues/1881 --- src/core/n-control.c | 13 ++++++++----- src/tests/units/evaluation-test.r3 | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/core/n-control.c b/src/core/n-control.c index 037ce70621..03c8c42ff1 100644 --- a/src/core/n-control.c +++ b/src/core/n-control.c @@ -569,7 +569,7 @@ enum { ***********************************************************************/ { REBVAL *value = D_ARG(1); - REBINT ret; + REBINT ret = R_RET; switch (VAL_TYPE(value)) { @@ -599,24 +599,27 @@ enum { ret = R_ARG1; break; -// case REB_PATH: ? is it used? + case REB_PATH: + Do_Path(&value, 0); + value = DS_POP; // volatile stack reference + if (ANY_FUNC(value)) VAL_SET_OPT(value, OPTS_REVAL); + *D_RET = *value; + break; case REB_WORD: case REB_GET_WORD: *D_RET = *Get_Var(value); - ret = R_RET; break; case REB_LIT_WORD: *D_RET = *value; SET_TYPE(D_RET, REB_WORD); - ret = R_RET; break; case REB_LIT_PATH: *D_RET = *value; SET_TYPE(D_RET, REB_PATH); - return R_RET; + break; case REB_ERROR: if (IS_THROW(value)) return R_ARG1; diff --git a/src/tests/units/evaluation-test.r3 b/src/tests/units/evaluation-test.r3 index 1854446724..c718f98048 100644 --- a/src/tests/units/evaluation-test.r3 +++ b/src/tests/units/evaluation-test.r3 @@ -162,6 +162,20 @@ Rebol [ ===end-group=== +===start-group=== "do path!" + + --test-- "do-path-1" + o: make object! [a: does ["OK"] b: 23] + --assert "OK" == do 'o/a + --assert 23 == do 'o/b + --assert all [error? e: try [do 'o/x] e/id = 'invalid-path] + + --test-- "do-path-2" + b: [["OK"]] + --assert ["OK"] == do first [b/1] + +===end-group=== + ===start-group=== "attempt" --test-- "issue-41" --assert none? attempt [2 / 0] ;@@ https://github.com/Oldes/Rebol-issues/issues/41