compile:forms/1 crashes
Ulf Wiger (AL/EAB)
ulf.wiger@REDACTED
Tue Oct 4 15:59:48 CEST 2005
Ok, pretty-printing the generated code, I found three bugs. :) ... :(
Still, if compile:forms/1 is going to be a documented function,
it could do with some front-end that catches errors and tries
to give less vitriolic feedback.
/Uffe
> -----Original Message-----
> From: Ulf Wiger (AL/EAB)
> Sent: den 4 oktober 2005 15:50
> To: 'erlang-questions@REDACTED'
> Subject: compile:forms/1 crashes
>
>
> Using compiler-4.3.9 (the latest one).
>
> I'm trying to generate some code, and am experiencing the
> lack of user-friendliness in compile:forms/1.
> Just about all errors in the generated forms manifest themselves
> as crashes in erl_lint or other. Below is a crash from beam_dead.
>
> I'm not sure whether this is a bug in my generated code, or in
> the compiler.
>
> /Uffe
>
>
> (foo@REDACTED)92> rdbms_validate:codegen([person], 1).
> [{attribute,1,module,rdbms_jit},
> ...
> (foo@REDACTED)93> io:format("~p~n", [v(92)]).
> [{attribute,1,module,rdbms_jit},
> {attribute,2,export,[{validate,2}]},
> {function,3,
> validate,
> 2,
> [{clause,3,
> [{atom,3,person},{var,3,'Object'}],
> [],
>
> [{call,3,{atom,3,validate_person},[{var,3,'Object'}]}]}]},
> {function,4,
> validate_person,
> 2,
> [{clause,4,
> [{atom,4,person},
> {tuple,4,
> [{var,4,person},
> {var,4,'V_id'},
> {var,4,'V_name'},
> {var,4,'V_addr'},
> {var,4,'V_age'}]}],
> [],
> [{'if',6,
> [{clause,6,
> [],
> [[{op,6,
> '=/=',
> {var,6,'V_id'},
> {atom,6,'#.[].#'}}]],
> [{atom,6,true}]},
> {clause,7,
> [],
> [[{atom,7,true}]],
> [{call,
> 8,
> {atom,8,throw},
> [{tuple,
> 8,
> [{atom,8,type_error},
> {atom,8,id},
> {tuple,
> 9,
> [{atom,9,expected},
>
> {atom,9,not_null}]}]}]}]}]},
> {'if',8,
> [{clause,8,
> [],
> [[{call,
> 8,
> {atom,8,is_integer},
> [{var,8,'V_age'}]}]],
> [{atom,8,true}]},
> {clause,9,
> [],
> [[{atom,9,true}]],
> [{call,
> 10,
> {atom,10,throw},
> [{tuple,
> 10,
> [{atom,10,type_error},
> {atom,10,age},
> {tuple,
> 11,
>
> [{atom,11,expected},
>
> {atom,11,integer}]}]}]}]}]},
>
> {call,10,{atom,10,validate_oid},[{var,10,'V_id'}]},
>
> {call,11,{atom,11,validate_string},[{var,11,'V_name'}]},
> {'if',12,
> [{clause,12,
> [],
> [[{op,12,
> '=<',
> {integer,12,0},
> {var,12,'V_age'}},
> {op,12,
> '=<',
> {var,12,'V_age'},
> {integer,12,100}}]],
> [{atom,12,true}]},
> {clause,13,
> [],
> [[{atom,13,true}]],
> [{call,
> 14,
> {atom,14,throw},
> [{tuple,
> 14,
> [{atom,14,value_error},
> {atom,14,age},
> {tuple,
> 15,
>
> [{atom,15,expected},
> {tuple,
> 15,
>
> [{atom,15,inclusive},
>
> {integer,15,0},
>
> {integer,15,100}]}]}]}]}]}]}]}]}]
> ok
> (foo@REDACTED)94> compile:forms(v(92)).
> .:none: internal error in beam_dead;
> crash reason: {{case_clause,{'EXIT',{function_clause,
> [{dict,fetch_val,[5,[]]},
> {beam_clean,find_all_used,3},
> {beam_clean,module,2},
> {beam_dead,module,2},
> {compile,
>
> '-select_passes/2-anonymous-2-',
> 2},
> {compile,
>
> '-internal_comp/4-anonymous-1-',
> 2},
> {compile,fold_comp,3},
>
> {compile,internal_comp,4}]}}},
> [{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}]}
> .:4: Warning: variable 'V_addr' is unused
> .:4: Warning: variable person is unused
> error
>
>
More information about the erlang-questions
mailing list