Open
Description
Describe the bug
A zip comprehension with an invalid generator (F()
) is not handled correctly.
To Reproduce
-module(c1).
-compile(export_all).
test1(F) -> [X || X <- [a, b] && F()].
$ erlc c1
erlc -S c1.erl
c1.erl: internal error in pass lint_module:
exception error: no function clause matching erl_lint:expr([],
[{'F',{bound,unused,[{4,7}]}}],
{lint,function,c1,[],
{2,{{module_info,1},{{module_info,0},nil,nil},nil}},
[],#{},
[report_warnings,report_errors,
{cwd,"/Users/ilyaklyuchnikov/code/otp"},
{outdir,"/Users/ilyaklyuchnikov/code/otp"},
'S',export_all],
#{},
{1,{{test1,1},nil,nil}},
{set,{0,nil}},
{4,
{{module_info,1},
{{module_info,0},nil,nil},
{{record_info,2},nil,{{test1,1},nil,nil}}}},
[],0,[],[],
{0,nil},
{test1,1},
[],1,
[behaviours,bif_clash,conflicting_behaviours,deprecated_callback,
deprecated_function,deprecated_type,export_all,
ill_defined_behaviour_callbacks,ill_defined_optional_callbacks,
match_float_zero,nif_inline,obsolete_guard,redefined_builtin_type,
removed,shadow_vars,undefined_behaviour,undefined_behaviour_callbacks,
undefined_behaviour_func,underscore_match,unexported_function,
unused_function,unused_record,unused_type,unused_vars,update_literal],
[],
[{"c1.erl",{{4,34},erl_lint,illegal_zip_generator}}],
[{"c1.erl",{{2,2},erl_lint,export_all}}],
"c1.erl",false,false,
[{{module_info,0},0},{{module_info,1},0},{{record_info,2},0}],
undefined,
{usage,#{{module_info,1} =>
[{module_info,0},{module_info,1},{record_info,2}]},
[],
{0,nil},
#{}},
#{},#{},#{},#{},#{},
{0,nil},
#{'maybe' => maybe_expr,'else' => maybe_expr},
none,guard,false,false,false}) (erl_lint.erl, line 2693)
in function erl_lint:exprs/3 (erl_lint.erl, line 2682)
in call from erl_lint:exprs/3 (erl_lint.erl, line 2683)
in call from erl_lint:handle_generators/4 (erl_lint.erl, line 4128)
in call from erl_lint:lc_quals/4 (erl_lint.erl, line 4076)
in call from erl_lint:lc_quals/3 (erl_lint.erl, line 4071)
in call from erl_lint:handle_comprehension/4 (erl_lint.erl, line 4035)
in call from erl_lint:exprs/3 (erl_lint.erl, line 2682)
A similar situation is with shell:
1> F = fun () -> [a, b] end.
#Fun<erl_eval.43.2783542>
2> [X || X <- [a, b] && F()].
** exception error: no function clause matching erl_lint:expr([],
[{'F',{bound,unused,[]}}],
{lint,start,'',[],
{2,{{module_info,1},{{module_info,0},nil,nil},nil}},
[],#{},
[bitlevel_binaries,binary_comprehension],
#{},
{0,nil},
{set,{0,nil}},
{3,
{{module_info,1},
{{module_info,0},nil,nil},
{{record_info,2},nil,nil}}},
...
Expected behavior
F()
is reported as an invalid generator
Affected versions
28.0-rc1
Activity