Skip to content

Commit bb45982

Browse files
committed
FIX: PARSE modifiers do not honor PROTECT status of series
fixes: Oldes/Rebol-issues#2290
1 parent 242ceba commit bb45982

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/core/u-parse.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,10 @@ void Print_Parse_Index(REBCNT type, REBVAL *rules, REBSER *series, REBCNT index)
10471047
Throw_Return_Series(parse->type, ser);
10481048
}
10491049
if (GET_FLAG(flags, PF_REMOVE)) {
1050-
if (count) Remove_Series(series, begin, count);
1050+
if (count) {
1051+
if (IS_PROTECT_SERIES(series)) Trap0(RE_PROTECTED);
1052+
Remove_Series(series, begin, count);
1053+
}
10511054
index = begin;
10521055
}
10531056
if (flags & (1<<PF_INSERT | 1<<PF_CHANGE)) {
@@ -1069,6 +1072,7 @@ void Print_Parse_Index(REBCNT type, REBVAL *rules, REBSER *series, REBCNT index)
10691072
}
10701073
if (IS_UNSET(item)) Trap1(RE_NO_VALUE, rules-1);
10711074
if (IS_END(item)) goto bad_end;
1075+
if (IS_PROTECT_SERIES(series)) Trap0(RE_PROTECTED);
10721076
if (IS_BLOCK_INPUT(parse)) {
10731077
index = Modify_Block(GET_FLAG(flags, PF_CHANGE) ? A_CHANGE : A_INSERT,
10741078
series, begin, item, cmd, count, 1);

src/tests/units/parse-test.r3

+24
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,30 @@ Rebol [
6060

6161
===end-group===
6262

63+
===start-group=== "Modifiers on protected series"
64+
;@@ https://github.com/Oldes/Rebol-issues/issues/2290
65+
s: protect "aaa"
66+
b: protect [1 2]
67+
--test-- "INSERT"
68+
--assert error? err: try [parse s [insert "a" to end]]
69+
--assert err/id = 'protected
70+
--assert error? err: try [parse b [insert "a" to end]]
71+
--assert err/id = 'protected
72+
73+
--test-- "REMOVE"
74+
--assert error? err: try [parse s [remove "a" to end]]
75+
--assert err/id = 'protected
76+
--assert error? err: try [parse b [remove integer! to end]]
77+
--assert err/id = 'protected
78+
79+
--test-- "CHANGE"
80+
--assert error? err: try [parse s [change "a" "b" to end]]
81+
--assert err/id = 'protected
82+
--assert error? err: try [parse s [change integer! "b" to end]]
83+
--assert err/id = 'protected
84+
85+
===end-group===
86+
6387
===start-group=== "DO"
6488

6589
--test-- "issue-2083"

0 commit comments

Comments
 (0)