Thanks to visit codestin.com
Credit goes to github.com

Skip to content

shell parsing error with an extra parenthesis and a a function reference #10294

@mkuratczyk

Description

@mkuratczyk

It's a minor issue, so feel free to ignore if you don't think it's worth fixing.

Describe the bug
There's an extra parenthesis in this expression, so I'd expect syntax error before: ')' error. However:

1> io:format("foo ~p", [ fun baz/0 ])).
*** ERROR: Shell process terminated! ***
=ERROR REPORT==== 17-Oct-2025::12:09:38.006429 ===
Error in process <0.89.0> with exit value:
{badarg,[{erl_anno,anno_info,
                   [{'fun',[{text,"fun"},{location,{1,23}}]},location,0],
                   [{file,"erl_anno.erl"},{line,503}]},
         {erl_eval,'-reset_anno/0-fun-0-',1,
                   [{file,"erl_eval.erl"},{line,2066}]},
         {erl_eval,'-reset_token_anno/1-lc$^0/1-0-',1,
                   [{file,"erl_eval.erl"},{line,2060}]},
         {erl_eval,'-reset_token_anno/1-lc$^0/1-0-',1,
                   [{file,"erl_eval.erl"},{line,2060}]},
         {erl_eval,extended_parse_exprs,1,[{file,"erl_eval.erl"},{line,2001}]},
         {shell,'-get_command/6-fun-2-',2,[{file,"shell.erl"},{line,466}]}]}

=ERROR REPORT==== 17-Oct-2025::12:09:38.006460 ===
Error in process <0.72.0> with exit value:
{{case_clause,{badarg,[{erl_anno,anno_info,
                                 [{'fun',[{text,"fun"},{location,{1,23}}]},
                                  location,0],
                                 [{file,"erl_anno.erl"},{line,503}]},
                       {erl_eval,'-reset_anno/0-fun-0-',1,
                                 [{file,"erl_eval.erl"},{line,2066}]},
                       {erl_eval,'-reset_token_anno/1-lc$^0/1-0-',1,
                                 [{file,"erl_eval.erl"},{line,2060}]},
                       {erl_eval,'-reset_token_anno/1-lc$^0/1-0-',1,
                                 [{file,"erl_eval.erl"},{line,2060}]},
                       {erl_eval,extended_parse_exprs,1,
                                 [{file,"erl_eval.erl"},{line,2001}]},
                       {shell,'-get_command/6-fun-2-',2,
                              [{file,"shell.erl"},{line,466}]}]}},
 [{shell,server_loop,8,[{file,"shell.erl"},{line,342}]}]}

If I remove the extra ), it works as expected and if I replace fun baz/0 with something else, it also works.
However, the combination of a function reference and an extra ) triggers a badarg.

To Reproduce
Try to execute io:format("foo ~p", [ fun baz/0 ])). in the shell

Affected versions
OTP 28.1 and older versions (eg. 26.2)

Metadata

Metadata

Assignees

Labels

bugIssue is reported as a bugteam:VMAssigned to OTP team VM

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions