From 9c132d619bb3b88201019a39d064f2852a067fb0 Mon Sep 17 00:00:00 2001 From: Tomas Abrahamsson Date: Thu, 15 Sep 2011 19:38:23 +0200 Subject: Quote atoms if necessary in types Atoms in some occurrences were not correctly quoted when formatted to strings, for instance by the typer program. Example: -module(tb). -export(['UPPERCASE-FUNCTION-NAME'/0, f1/0, f2/0, f3/0]). -record('UPPERCASE-RECORD-NAME', {x}). -record(r2, {'UPPERCASE-FIELD-NAME'}). -type 'UPPERCASE-TYPE-NAME'() :: integer(). 'UPPERCASE-FUNCTION-NAME'() -> ok. f1() -> #'UPPERCASE-RECORD-NAME'{x=1}. f2() -> #r2{'UPPERCASE-FIELD-NAME'=1}. -spec f3() -> 'UPPERCASE-TYPE-NAME'(). f3() -> 1. Given the program above, the output from typer --plt some.plt tb.erl resulted in the following specs being printed: -spec UPPERCASE-FUNCTION-NAME() -> 'ok'. -spec f1() -> #UPPERCASE-RECORD-NAME{x::1}. -spec f2() -> #r2{UPPERCASE-FIELD-NAME::1}. -spec f3() -> UPPERCASE-TYPE-NAME(). This commit changes the output to become the following: -spec 'UPPERCASE-FUNCTION-NAME'() -> 'ok'. -spec f1() -> #'UPPERCASE-RECORD-NAME'{x::1}. -spec f2() -> #r2{'UPPERCASE-FIELD-NAME'::1}. -spec f3() -> 'UPPERCASE-TYPE-NAME'(). --- lib/typer/src/typer.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/typer/src/typer.erl') diff --git a/lib/typer/src/typer.erl b/lib/typer/src/typer.erl index e40c4f39cd..fd906c8c46 100644 --- a/lib/typer/src/typer.erl +++ b/lib/typer/src/typer.erl @@ -539,7 +539,7 @@ get_type_string(F, A, Info, Mode) -> case {Mode, Type} of {file, {contract, _}} -> ""; _ -> - Prefix = lists:concat(["-spec ", F]), + Prefix = lists:concat(["-spec ", erl_types:atom_to_string(F)]), lists:concat([Prefix, TypeStr, "."]) end; true -> -- cgit v1.2.3