aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dialyzer/test/race_SUITE_data/src/whereis_try_catch.erl
blob: 39bb440f56da7958e8be2ddba6874901425513c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
% This tests that warnings do appear when a whereis/register combination
% is handled by try/catch.

-module(whereis_try_catch).
-export([race/1, no_race/1]).

race(Pid) ->
  case whereis(master) of
    undefined ->
      try
	io:format("exception", [])
      catch
        _ -> register(master, Pid)
      end
  end.

no_race(Pid) ->
  case whereis(master) of
    undefined ->
      try
        register(master, Pid)
      catch
        _ -> io:format("exception", [])
      end
  end.