Erlang の smart_exception で例外が変になる
smart_exception をデフォルトで使うようにしていたのだけど,どうも例外がおかしくなってしまう模様.
これじゃ使えないじゃない.しょんぼり.
とりあえず家に帰ったらTipsからはいったん消しておこう.
これははまる.
以下のようなコードで確認できる.
-module(exception). -export([test/0]).test() ->
try
test2()
catch
Ex -> io:format("Catch ~p~n", [Ex])
end.test2() ->
throw(exception),
io:format("throwed exception~n").
これを smart_exception 有り無しで実行すると・・・
$ erlc exception.erl && erl -noshell -run exception test -run init stop Catch exception$ erlc +'{parse_transform, smart_exceptions}' exception.erl && erl -noshell -run exception test -run init stop
throwed exception
こうなってしまい,smart_exception を使うと,throwが無視されてしまう...
----
追記.
氷魚にゃさんが原因を見つけてくれた.
smart_exceptions.erl の
%% define r10 means 'try' is used in the generated code rather
%% than 'catch'. Note that try is _handled_ by default.
%% -define(r10, true).
となっているところの -define をコメントアウトして
-define(r10, true).
とすると直る模様.
「R10B compatibility is weak, not very tested」と書いてあるところが
多少不安だけども(^^;
(すでにR11Bだし)
----
Erlang Tipsの方も修正しました.
インストールされた方は,お手数ですがもう1回入れ直してください.
tar.gzのアーカイブも新しいものに差し替えました.
The comments to this entry are closed.
Comments