Skip to content

Commit fdf662b

Browse files
committed
FIX: does not allow refinement ending with a colon char
resolves: Oldes/Rebol-issues#2281
1 parent 409c96e commit fdf662b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/boot/strings.reb

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ scan: ; Used by scanner. Keep in sync with Value_Types in scan.h file!
5050
"issue"
5151
"tag"
5252
"path"
53+
"ref"
5354
"refine"
5455
"construct"
5556
"map"

src/core/l-scan.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,10 @@
997997
scan_state->begin--;
998998
type = TOKEN_REFINE;
999999
// Fast easy case:
1000-
if (ONLY_LEX_FLAG(flags, LEX_SPECIAL_WORD)) return type;
1000+
if (ONLY_LEX_FLAG(flags, LEX_SPECIAL_WORD))
1001+
return type;
1002+
if (*(scan_state->end - 1) == ':')
1003+
return -type;
10011004
goto scanword;
10021005
}
10031006
if (*cp == '<' || *cp == '>') {
@@ -1414,14 +1417,15 @@
14141417
np = Skip_Left_Arrow(cp);
14151418
if (!np) return -type;
14161419
scan_state->end = np;
1417-
return type;
14181420
}
14191421
else {
14201422
np = Skip_Right_Arrow(cp);
14211423
if (!np) return -type;
14221424
scan_state->end = np;
1423-
return type;
14241425
}
1426+
if (type == TOKEN_REFINE && (*(scan_state->end - 1)) == ':')
1427+
type = -type;
1428+
return type;
14251429
}
14261430

14271431

src/tests/units/lexer-test.r3

+4
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ Rebol [
153153
--assert all [error? e: try [load {%a^^b}] e/id = 'invalid]
154154
--assert all [error? e: try [load {%a^^ }] e/id = 'invalid]
155155

156+
--test-- "Invalid refine"
157+
;@@ https://github.com/Oldes/Rebol-issues/issues/2281
158+
--assert all [error? e: try [load {/a:}] e/id = 'invalid]
159+
156160
===end-group===
157161

158162

0 commit comments

Comments
 (0)