Skip to content

Commit

Permalink
CHANGE: do path! behavior made compatible with Rebol2 and Red
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jul 4, 2022
1 parent 8c92c8c commit 2d91e51
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/core/n-control.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ enum {
***********************************************************************/
{
REBVAL *value = D_ARG(1);
REBINT ret;
REBINT ret = R_RET;

switch (VAL_TYPE(value)) {

Expand Down Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions src/tests/units/evaluation-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2d91e51

Please sign in to comment.