[erlang-bugs] Updating key in empty map doesn't fail

Björn-Egil Dahlberg wallentin.dahlberg@REDACTED
Sun Feb 9 20:37:42 CET 2014


Thank you for reporting. I believe that this particular bug (among others)
has already been fixed:

https://github.com/erlang/otp/commit/963c06a5b72c2ac8d88a6910ee60248d6dca747d

I aim to have rc2 even more stable. =)

// Björn-Egil


2014-02-09 14:37 GMT+01:00 Lars Hesel Christensen <lars@REDACTED>:

> Hi All
>
> I'm playing around with the maps in Erlang R17 rc1, and discovered
> something unexpected (at least for me): When updating an empty map with
> a key, the runtime system doesn't complain!
>
> If I define a module with one function that updates a key in the map
> given as an argument:
>
>    -module(maps_test).
>    -compile(export_all).
>    update_key(Map) ->
>        Map#{key := val}.
>
> Then updating an existing key works as expected:
>
>    1> maps_test:update_key(#{key => hello}).
>    #{key => val}
>
> Trying to update a non-existing key in a non-empty map fails as expected
> as well:
>
>    2> maps_test:update_key(#{non_existing_key => hello}).
>    ** exception error: bad argument
>         in function  maps_test:update_key/1 (maps_test.erl, line 4)
>
> Updating a non-existing key in an emtpy-map does NOT fail as expected:
>
>    3> maps_test:update_key(#{}).
>    #{key => val}
>
> I would expect ':=' to behave the same regardless if it is operating on
> an empty map or not.
>
> Maybe this has already been noticed, discussed, explained here or
> somewhere else, but so far I didn't find anything about this behaviour.
>
> A bug, maybe?
>
> Cheers,
> Lars
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://erlang.org/mailman/listinfo/erlang-bugs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20140209/4854414b/attachment.htm>


More information about the erlang-bugs mailing list