Browse Source

Use `OTP_RELEASE` macro for detecting the existence of the new try/catch syntax

Takeru Ohta 6 years ago
parent
commit
775b3d02eb
3 changed files with 8 additions and 7 deletions
  1. 1 1
      doc/jsone.md
  2. 1 2
      rebar.config
  3. 6 4
      src/jsone.erl

+ 1 - 1
doc/jsone.md

@@ -214,7 +214,7 @@ json_object() = <a href="#type-json_object_format_tuple">json_object_format_tupl
 
 
 <pre><code>
-json_object_format_map() = #{}
+json_object_format_map() = map()
 </code></pre>
 
 

+ 1 - 2
rebar.config

@@ -5,8 +5,7 @@
             warn_untyped_record,
             inline,
             {platform_define, "^R[01][0-9]", 'NO_MAP_TYPE'},
-            {platform_define, "(^R|17)", 'NO_DIALYZER_SPEC'},
-            {platform_define, "^(R|1|20)", 'FUN_STACKTRACE'}
+            {platform_define, "(^R|17)", 'NO_DIALYZER_SPEC'}
            ]}.
 
 {xref_checks, [

+ 6 - 4
src/jsone.erl

@@ -265,12 +265,14 @@
 %% but it is not exported from the module.
 %% So, maybe as a temporary measure, we redefine this type for passing full dialyzer analysis.
 
--ifdef('FUN_STACKTRACE').
--define(CAPTURE_STACKTRACE, ).
--define(GET_STACKTRACE, erlang:get_stacktrace()).
--else.
+-ifdef('OTP_RELEASE').
+%% The 'OTP_RELEASE' macro introduced at OTP-21,
+%% so we can use it for detecting whether the Erlang compiler supports new try/catch syntax or not.
 -define(CAPTURE_STACKTRACE, :__StackTrace).
 -define(GET_STACKTRACE, __StackTrace).
+-else.
+-define(CAPTURE_STACKTRACE, ).
+-define(GET_STACKTRACE, erlang:get_stacktrace()).
 -endif.
 
 %%--------------------------------------------------------------------------------