Skip to content

erlc folds away an unused map update that should throw an exception #6960

@RobinMorisset

Description

@RobinMorisset

To Reproduce
Running the following code:

f1() ->
    (#{}#{ok := ok}),
    'hello'.

wrapper0() ->
    io:write(catch f1()).

with the following:

erlc ~/minimized/divergence.erl
erl -noshell -pa . -s divergence wrapper0 -s init stop

outputs hello.

Expected behavior
I would expect a tuple containing an exception, since the map update operation is supposed to throw with badarg in this context (https://www.erlang.org/doc/reference_manual/expressions.html#map-expressions).

Affected versions
master

Additional context
Giving the argument +no_fold to erlc fixes this bug, resulting in the following output:

{'EXIT',{{badkey,ok},[{divergence,f1,0,[{file,[47,104,111,109,101,47,114,109,111,114,105,115,115,101,116,47,109,105,110,105,109,105,122,101,100,47,100,105,118,101,114,103,101,110,99,101,46,101,114,108]},{line,13}]},{divergence,wrapper0,0,[{file,[47,104,111,109,101,47,114,109,111,114,105,115,115,101,116,47,109,105,110,105,109,105,122,101,100,47,100,105,118,101,114,103,101,110,99,101,46,101,114,108]},{line,17}]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}

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