Skip to content

Commit

Permalink
FIX: does not allow refinement ending with a colon char
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Apr 10, 2024
1 parent 409c96e commit fdf662b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/boot/strings.reb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ scan: ; Used by scanner. Keep in sync with Value_Types in scan.h file!
"issue"
"tag"
"path"
"ref"
"refine"
"construct"
"map"
Expand Down
10 changes: 7 additions & 3 deletions src/core/l-scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,10 @@
scan_state->begin--;
type = TOKEN_REFINE;
// Fast easy case:
if (ONLY_LEX_FLAG(flags, LEX_SPECIAL_WORD)) return type;
if (ONLY_LEX_FLAG(flags, LEX_SPECIAL_WORD))
return type;
if (*(scan_state->end - 1) == ':')
return -type;
goto scanword;
}
if (*cp == '<' || *cp == '>') {
Expand Down Expand Up @@ -1414,14 +1417,15 @@
np = Skip_Left_Arrow(cp);
if (!np) return -type;
scan_state->end = np;
return type;
}
else {
np = Skip_Right_Arrow(cp);
if (!np) return -type;
scan_state->end = np;
return type;
}
if (type == TOKEN_REFINE && (*(scan_state->end - 1)) == ':')
type = -type;
return type;
}


Expand Down
4 changes: 4 additions & 0 deletions src/tests/units/lexer-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ Rebol [
--assert all [error? e: try [load {%a^^b}] e/id = 'invalid]
--assert all [error? e: try [load {%a^^ }] e/id = 'invalid]

--test-- "Invalid refine"
;@@ https://github.com/Oldes/Rebol-issues/issues/2281
--assert all [error? e: try [load {/a:}] e/id = 'invalid]

===end-group===


Expand Down

0 comments on commit fdf662b

Please sign in to comment.