Skip to content

Erlang pass rewrite change arguments order #15313

@josevalim

Description

@josevalim

An there is one more detail:

translate_remote(maps, put, Meta, [Key, Value, Map], S) ->
Ann = ?ann(Meta),
case translate_args([Key, Value, Map], Ann, S) of
{[TKey, TValue, {map, _, InnerMap, Pairs}], TS} ->
{{map, Ann, InnerMap, Pairs ++ [{map_field_assoc, Ann, TKey, TValue}]}, TS};
{[TKey, TValue, {map, _, Pairs}], TS} ->
{{map, Ann, Pairs ++ [{map_field_assoc, Ann, TKey, TValue}]}, TS};
{[TKey, TValue, TMap], TS} ->
{{map, Ann, TMap, [{map_field_assoc, Ann, TKey, TValue}]}, TS}

rewrites :maps.put(key, value, map) into map update Map#{Key => Value}, which evaluates Map first. This makes raw :maps.put/3 affected by the bug but by chance negates the bug for Map.put

Originally posted by @lukaszsamson in #15310

The best option is to not rewrite/inline "Map.put/3" and we rewrite Map.put/3 in the Erlang compiler instead. I will open up a separate issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions