diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2017-05-27 20:06:40 +0200 |
---|---|---|
committer | José Valim <jose.valim@plataformatec.com.br> | 2017-05-27 20:06:40 +0200 |
commit | 6517ca0051ad5b9a71852898f17c75ef9c373a0b (patch) | |
tree | 750d42128049932f11f555d7c38a968fbdf8a663 /lib/elixir/src/elixir_tokenizer.erl | |
parent | efba1e7736ebde555031144eb96ab799f057ae38 (diff) | |
download | elixir-jv-unicode.tar.gz |
Add error messages to invalid non-NFC identifiersjv-unicode
Diffstat (limited to 'lib/elixir/src/elixir_tokenizer.erl')
-rw-r--r-- | lib/elixir/src/elixir_tokenizer.erl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/elixir/src/elixir_tokenizer.erl b/lib/elixir/src/elixir_tokenizer.erl index c5b810625..aef779e6f 100644 --- a/lib/elixir/src/elixir_tokenizer.erl +++ b/lib/elixir/src/elixir_tokenizer.erl @@ -861,10 +861,23 @@ tokenize_identifier(String, Line, Scope) -> {error, _Reason} = Error -> Error end; + {error, {not_nfc, Wrong}} -> + Right = unicode:characters_to_nfc_list(Wrong), + RightCodepoints = list_to_codepoint_hex(Right), + WrongCodepoints = list_to_codepoint_hex(Wrong), + Message = io_lib:format("Elixir expects unquoted Unicode atoms and variables to be in NFC form.\n" + "Got: \"~ts\" (codepoints~ts)\n" + "Expected: \"~ts\" (codepoints~ts)\n + Syntax error before: ", + [Wrong, WrongCodepoints, Right, RightCodepoints]), + {error, {Line, Message, Wrong}}; {error, empty} -> empty end. +list_to_codepoint_hex(List) -> + [io_lib:format(" ~4.16.0B", [Codepoint]) || Codepoint <- List]. + tokenize_alias(Rest, Line, Column, Atom, Length, Ascii, Special, Scope, Tokens) -> if not Ascii -> |