Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:20
erlang
1451-dialyzer-Don-t-crash-when-specs-types-cont...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1451-dialyzer-Don-t-crash-when-specs-types-contain-emojis.patch of Package erlang
From 4ea15bcb9d9398c8ffa5edb00b83bea181b482a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org> Date: Mon, 20 Sep 2021 12:25:36 +0200 Subject: [PATCH] dialyzer: Don't crash when specs/types contain emojis or similar --- lib/dialyzer/src/dialyzer.erl | 4 ++-- lib/dialyzer/test/dialyzer_common.erl | 2 +- lib/dialyzer/test/opaque_SUITE_data/results/unicode | 2 ++ .../test/opaque_SUITE_data/src/unicode/exposer.erl | 5 +++++ .../test/opaque_SUITE_data/src/unicode/problematic.erl | 9 +++++++++ 5 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 lib/dialyzer/test/opaque_SUITE_data/results/unicode create mode 100644 lib/dialyzer/test/opaque_SUITE_data/src/unicode/exposer.erl create mode 100644 lib/dialyzer/test/opaque_SUITE_data/src/unicode/problematic.erl diff --git a/lib/dialyzer/src/dialyzer.erl b/lib/dialyzer/src/dialyzer.erl index 2fc0767a01..32dcb25544 100644 --- a/lib/dialyzer/src/dialyzer.erl +++ b/lib/dialyzer/src/dialyzer.erl @@ -725,14 +725,14 @@ pp_type(Type) -> Form = {attribute, erl_anno:new(0), type, {t, Type, []}}, TypeDef = erl_pp:form(Form, [{quote_singleton_atom_types, true}]), {match, [S]} = re:run(TypeDef, <<"::\\s*(.*)\\.\\n*">>, - [{capture, all_but_first, list}, dotall]), + [{capture, all_but_first, list}, dotall, unicode]), S. pp_spec(Spec) -> Form = {attribute, erl_anno:new(0), spec, {{a,b,0}, Spec}}, Sig = erl_pp:form(Form, [{quote_singleton_atom_types, true}]), {match, [S]} = re:run(Sig, <<"-spec a:b\\s*(.*)\\.\\n*">>, - [{capture, all_but_first, list}, dotall]), + [{capture, all_but_first, list}, dotall, unicode]), S. parse_types_and_literals(Src) -> diff --git a/lib/dialyzer/test/dialyzer_common.erl b/lib/dialyzer/test/dialyzer_common.erl index beaf126344..392c41306e 100644 --- a/lib/dialyzer/test/dialyzer_common.erl +++ b/lib/dialyzer/test/dialyzer_common.erl @@ -154,7 +154,7 @@ check(TestCase, Opts, Dir, OutDir) -> _ -> case file:open(NewResFile,[?output_file_mode]) of {ok, OutFile} -> - io:format(OutFile,"\n~s",[Warns]), + file:write(OutFile, [$\n, unicode:characters_to_binary(Warns)]), file:close(OutFile); Other -> erlang:error(Other) end diff --git a/lib/dialyzer/test/opaque_SUITE_data/results/unicode b/lib/dialyzer/test/opaque_SUITE_data/results/unicode new file mode 100644 index 0000000000..9cdab6d60d --- /dev/null +++ b/lib/dialyzer/test/opaque_SUITE_data/results/unicode @@ -0,0 +1,2 @@ + +exposer.erl:5:26: The call problematic:'🔍'('bug') does not have an opaque term of type problematic:'🐛'() as 1st argument diff --git a/lib/dialyzer/test/opaque_SUITE_data/src/unicode/exposer.erl b/lib/dialyzer/test/opaque_SUITE_data/src/unicode/exposer.erl new file mode 100644 index 0000000000..618f053532 --- /dev/null +++ b/lib/dialyzer/test/opaque_SUITE_data/src/unicode/exposer.erl @@ -0,0 +1,5 @@ +-module(exposer). + +-export(['💣'/0]). + +'💣'() -> problematic:'🔍'(bug). diff --git a/lib/dialyzer/test/opaque_SUITE_data/src/unicode/problematic.erl b/lib/dialyzer/test/opaque_SUITE_data/src/unicode/problematic.erl new file mode 100644 index 0000000000..c841b1a511 --- /dev/null +++ b/lib/dialyzer/test/opaque_SUITE_data/src/unicode/problematic.erl @@ -0,0 +1,9 @@ +-module(problematic). + +-opaque '🐛'() :: bug. +-export_type(['🐛'/0]). + +-export(['🔍'/1]). + +-spec '🔍'('🐛'()) -> true. +'🔍'(bug) -> true. -- 2.31.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor