Skip to content

Commit 0e12d3d

Browse files
authored
Fix valid character range computation for compilation units (#1110)
1 parent d7b2c20 commit 0e12d3d

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

ocaml/utils/compilation_unit.ml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,10 @@ end = struct
138138
end)
139139

140140
let is_valid_character first_char c =
141-
let code = Char.code c in
142-
if first_char
143-
then code >= 65 && code <= 90 (* [A-Z] *)
144-
else
145-
Char.equal c '_'
146-
|| (code >= 48 && 57 <= 90 (* [0-9] *))
147-
|| (code >= 65 && code <= 90 (* [A-Z] *))
148-
|| (code >= 97 && code <= 122 (* [a-z] *))
141+
match c with
142+
| 'A' .. 'Z' -> true
143+
| '_' | '0' .. '9' | 'a' .. 'z' -> not first_char
144+
| _ -> false
149145

150146
let parse_for_pack pack =
151147
let prefix = String.split_on_char '.' pack in

0 commit comments

Comments
 (0)