[erlang-bugs] R13A Internal compiler error when using a record in a guard within a try/catch block

David Sveningsson ext@REDACTED
Thu Apr 16 14:40:35 CEST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, when compiling the attached code with R13A erlc the compiler crashes
with the following error:

Function: do_stuff/1
temp/test.erl:none: internal error in v3_codegen;
crash reason: {{case_clause,
                   {'EXIT',
                       {function_clause,
                           [{v3_codegen,longest,[[{ker0}],[]]},
                            {v3_codegen,longest,2},
                            {v3_codegen,sr_merge,2},
                            {v3_codegen,match_cg,5},
                            {v3_codegen,guard_match_cg,6},
                            {v3_codegen,guard_cg,5},
                            {v3_codegen,'-guard_cg_list/6-anonymous-0-',4},
                            {v3_codegen,flatmapfoldl,3}]}}},
               [{compile,'-select_passes/2-anonymous-2-',2},
                {compile,'-internal_comp/4-anonymous-1-',2},
                {compile,fold_comp,3},
                {compile,internal_comp,4},
                {compile,internal,3}]}

There are many ways to workaround this:

* Removing the try/catch block.
* Putting the case block in a separate functions.
* Assigning Foo#foo.bar to a local variable and use in guard instead.

Either way, the compiler shouldn't crash. It is possible that this issue
is already fixed as I've read some similar reports related to try/catch.

- -module(test).
- -export([start/0]).

- -record(foo, {
	bar = false :: bool()
}).

start() ->
	do_stuff(#foo{bar=true}).

do_stuff(Foo) ->
	try
		case fred:barney() of
			_ when Foo#foo.bar =:= true -> a;
			_ when Foo#foo.bar =:= false -> b
		end
	catch
		_ -> error
	end.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAknnJ0MACgkQ6pa1H/H5pqV4ogCfWAhJ+I+ogKcRpk6XxCSzRc0r
iRUAn39B2HxuQlkDIUWv15crYJf/20LS
=PJ+9
-----END PGP SIGNATURE-----



More information about the erlang-bugs mailing list