Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evaluate map expression and pattern matching #185

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

neoaggelos
Copy link
Contributor

@neoaggelos neoaggelos commented Sep 25, 2021

Summary

References #183. Support expressions and pattern matching for Erlang maps.

This PR can be reviewed and merged separately from #184, but any future work on maps greatly depends on these two PRs getting merged.

Changes

  • Annotate all children of map and map_pair nodes. This is required for pattern matching to work properly.
  • Support {c_map, ...} (maps) and {c_map_pair, ...} (key-value pairs) nodes in eval_expr/6.
  • Support {c_map, ...} (maps) and {c_map_pair, ...} (key-value pairs) nodes in pattern_match/9
  • Initial support for the maps standard library (maps:get, maps:put and is_map).
  • Extend suite of functional tests to cover map value expressions, as well as pattern matching cases.

Testing

  • Functional tests. Each test case was introduced after manually testing the different ways that maps can be evaluated and/or matched in Erlang code.

Notes

  • Background and context for the implementation in Support Erlang maps #183 (comment).
  • Supports maps:get and maps:put from the standard library as well. The rest of the standard library (e.g. maps:from_list, maps:to_list) is not straightforward to support and will be added in a separate PR.
  • This PR makes cuter recognize and correctly handle map values and patterns. It does not add any logic regarding symbolic map values and how they can be handled, this will be done separately.
  • For all examples, --disable-pmatch is required, since map values are not handled.

This commit introduces support for evaluating map expressions and
matching patterns containing maps. It also adds initial support
for the maps:get() and maps:put() standard library functions.
@neoaggelos neoaggelos mentioned this pull request Oct 31, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants