Skip to content

Commit 849e4a2

Browse files
committed
allow No to start identifier, but disallow all-No identifiers
1 parent 27a63e5 commit 849e4a2

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

NEWS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ Language changes
641641
642642
* Identifiers can now start with numeric symbols in category
643643
[No: Number, other](http://www.fileformat.info/info/unicode/category/No/list.htm),
644-
allowing you to have variables with names like `⅓` or `¹x₂` ([#20278]).
644+
allowing you to have variables with names like `⅓x` or `¹x₂` ([#20278]).
645645
646646
* `@.` is now parsed as `@__dot__`, and can be used to add dots to
647647
every function call, operator, and assignment in an expression ([#20321]).

src/flisp/julia_extensions.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,11 @@ value_t fl_accum_julia_symbol(fl_context_t *fl_ctx, value_t *args, uint32_t narg
269269
type_error(fl_ctx, "accum-julia-symbol", "wchar", args[0]);
270270
uint32_t wc = *(uint32_t*)cp_data((cprim_t*)ptr(args[0]));
271271
ios_t str;
272-
int allascii=1;
272+
int allascii=1, allNo=1;
273273
ios_mem(&str, 0);
274274
do {
275275
allascii &= (wc <= 0x7f);
276+
allNo = allNo && UTF8PROC_CATEGORY_NO == utf8proc_category((utf8proc_int32_t) wc);
276277
ios_getutf8(s, &wc);
277278
if (wc == '!') {
278279
uint32_t nwc;
@@ -288,6 +289,8 @@ value_t fl_accum_julia_symbol(fl_context_t *fl_ctx, value_t *args, uint32_t narg
288289
break;
289290
} while (jl_id_char(wc));
290291
ios_pututf8(&str, 0);
292+
if (allNo) /* identifiers cannot consist only of category-No */
293+
lerrorf(fl_ctx, symbol(fl_ctx, "error"), "invalid identifier %s", str.buf);
291294
return symbol(fl_ctx, allascii ? str.buf : normalize(fl_ctx, str.buf));
292295
}
293296

test/parse.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1078,8 +1078,8 @@ short_where_call = :(f(x::T) where T = T)
10781078
@test short_where_call.args[2].head == :block
10791079

10801080
# identifiers starting with category No:
1081-
let ⅟₉₉ = 1/99, ¹x = 12
1082-
@test ⅟₉₉ == 1/99
1081+
let ⅟₉₉x = 1/99, ¹x = 12
1082+
@test ⅟₉₉x == 1/99
10831083
@test ¹x == 12
10841084
end
10851085
# `where` with multi-line anonymous functions

0 commit comments

Comments
 (0)