Skip to content

Commit 40083e5

Browse files
earlOldes
authored andcommitted
FIX: PARSE position capture combined with SET or COPY
The recent extension to allow set-word! usage in SET and COPY rules introduced a regression: set-word!s (for position capture) in the rule immediately following a `SET word` or `COPY word` rule cause a match failure. For example: >> parse [x] [set val pos: word!] == false ;; Expected: true This commit fixes Oldes/Rebol-issues#2130, a regression caused by 8db79a9. Corresponding tests have been added to the test suite (rebolsource/rebol-test@fe8df53). (cherry picked from commit f540883)
1 parent 6e8d2ad commit 40083e5

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/core/u-parse.c

+2-5
Original file line numberDiff line numberDiff line change
@@ -816,11 +816,8 @@ void Print_Parse_Index(REBCNT type, REBVAL *rules, REBSER *series, REBCNT index)
816816

817817
} else { // It's not a PARSE command, get or set it:
818818

819-
// word: - if not the target of a COPY or SET operation, this will
820-
// default to setting a variable to the series at current index
821-
if (IS_SET_WORD(item) &&
822-
!(GET_FLAG(flags, PF_SET_OR_COPY) || GET_FLAG(flags, PF_COPY)))
823-
{
819+
// word: - set a variable to the series at current index
820+
if (IS_SET_WORD(item)) {
824821
Set_Var_Series(item, parse->type, series, index);
825822
continue;
826823
}

src/tests/units/parse-test.r3

+9
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,13 @@ Rebol [
9595
===end-group===
9696

9797

98+
===start-group=== "Other parse issues"
99+
100+
--test-- "issue-2130"
101+
;@@ https://github.com/Oldes/Rebol-issues/issues/2130
102+
--assert parse [x][set val pos: word!]
103+
--assert pos = [x]
104+
105+
===end-group===
106+
98107
~~~end-file~~~

0 commit comments

Comments
 (0)