Skip to content

Commit 4dc5b41

Browse files
committed
FIX: Path evaluation does not process THROWN values as THROWN
resolves: Oldes/Rebol-issues#2243
1 parent 8429397 commit 4dc5b41

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/core/c-do.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,10 @@ void Trace_Arg(REBINT num, REBVAL *arg, REBVAL *path)
433433
pvs->value = pvs->store;
434434
break;
435435
case PE_BAD_SELECT:
436+
if (THROWN(pvs->select)) {
437+
pvs->value = pvs->select;
438+
return;
439+
}
436440
Trap2(RE_INVALID_PATH, pvs->orig, pvs->path);
437441
case PE_BAD_SET:
438442
Trap2(RE_BAD_PATH_SET, pvs->orig, pvs->path);
@@ -491,15 +495,19 @@ void Trace_Arg(REBINT num, REBVAL *arg, REBVAL *path)
491495
Next_Path(&pvs);
492496
// Check for errors:
493497
if (NOT_END(pvs.path+1) && !ANY_FUNC(pvs.value)) {
498+
if (THROWN(pvs.value)) goto thrown;
494499
// Only function refinements should get by this line:
495500
Trap2(RE_INVALID_PATH, pvs.orig, pvs.path);
496501
}
497502
}
498-
else if (NOT_END(pvs.path+1) && !ANY_FUNC(pvs.value))
503+
else if (NOT_END(pvs.path+1) && !ANY_FUNC(pvs.value)) {
504+
if (THROWN(pvs.value)) goto thrown;
499505
Trap2(RE_BAD_PATH_TYPE, pvs.orig, Of_Type(pvs.value));
506+
}
500507

501508
// If SET then we can drop result storage created above.
502509
if (val) {
510+
if (THROWN(pvs.value)) goto thrown;
503511
DS_DROP; // on SET, we do not care about returned value
504512
return 0;
505513
} else {
@@ -511,6 +519,10 @@ void Trace_Arg(REBINT num, REBVAL *arg, REBVAL *path)
511519
*path_val = pvs.path; // return new path (for func refinements)
512520
return pvs.value; // only used for functions
513521
}
522+
thrown:
523+
if (val) DS_DROP;
524+
*DS_TOP = *pvs.value;
525+
return 0;
514526
}
515527

516528

src/tests/units/evaluation-test.r3

+8
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,14 @@ Rebol [
804804
--assert error? catch [make error! [type: 'Access arg1: 10 + 20 id: 'Protocol]]
805805
--assert 30 = catch [make error! [type: 'Access arg1: throw 10 + 20 id: 'Protocol]]
806806

807+
--test-- "throw from path evaluation"
808+
;@@ https://github.com/Oldes/Rebol-issues/issues/2243
809+
foo: object [bar: 1]
810+
--assert "ok" = catch [foo/(throw "ok" 'bar)]
811+
--assert "ok" = catch [foo/(throw "ok" 'bar): 3]
812+
--assert "ok" = catch [foo/(throw "ok" 'bar)/xx]
813+
--assert "ok" = catch [foo/(throw "ok" 'bar)/xx: 3]
814+
807815
===end-group===
808816

809817

0 commit comments

Comments
 (0)