diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-10-03 18:07:49 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-10-03 18:07:49 +0200 |
commit | 7f6030a49b0bc47aadba62a7382dc77dde3a7f87 (patch) | |
tree | dc30437ab410938285baf2bec315f20e692dd287 /lib/compiler/src/sys_pre_expand.erl | |
parent | 3a865c0cd9a97aedc20c70f69a60fcc23eb4b4d0 (diff) | |
parent | d01120a2450fd0b44df64f2e58ae3833d01470b0 (diff) | |
download | otp-7f6030a49b0bc47aadba62a7382dc77dde3a7f87.tar.gz otp-7f6030a49b0bc47aadba62a7382dc77dde3a7f87.tar.bz2 otp-7f6030a49b0bc47aadba62a7382dc77dde3a7f87.zip |
Merge branch 'egil/maps/variable-keys/OTP-12218'
* egil/maps/variable-keys/OTP-12218: (22 commits)
compiler: Update test for Maps aliasing
compiler: Properly support Map aliasing
compiler: Refactor Map pairs aliasing
compiler: Fix harmless need_heap error for Maps
stdlib: Update Map tests
stdlib: Use environment bindings for Maps keys in erl_eval matching
debugger: Update Map tests
compiler: Update Map tests
compiler: Fix v3_core Maps pair chains
compiler: Use expressions in core patterns
compiler: Use variables in Map cerl inliner
compiler: Reintroduce binary limit for Map keys
compiler: Shameless v3_core hack for variables
compiler: Use variables in Map beam assmebler
compiler: Use variables in Map kernel pass
compiler: Use variables in Map core pass
compiler: Normalize unary ops on Maps key literals
stdlib: Update Map tests
stdlib: erl_lint Map key variables
compiler: Maps are always patterns never values in matching
...
Diffstat (limited to 'lib/compiler/src/sys_pre_expand.erl')
-rw-r--r-- | lib/compiler/src/sys_pre_expand.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/compiler/src/sys_pre_expand.erl b/lib/compiler/src/sys_pre_expand.erl index 6410b73941..f99307c865 100644 --- a/lib/compiler/src/sys_pre_expand.erl +++ b/lib/compiler/src/sys_pre_expand.erl @@ -262,9 +262,18 @@ pattern({map,Line,Ps}, St0) -> {TPs,St1} = pattern_list(Ps, St0), {{map,Line,TPs},St1}; pattern({map_field_exact,Line,K0,V0}, St0) -> - {K,St1} = expr(K0, St0), + %% Key should be treated as an expression + %% but since expressions are not allowed yet, + %% process it through pattern .. and handle assoc + %% (normalise unary op integer -> integer) + {K,St1} = pattern(K0, St0), {V,St2} = pattern(V0, St1), {{map_field_exact,Line,K,V},St2}; +pattern({map_field_assoc,Line,K0,V0}, St0) -> + %% when keys are Maps + {K,St1} = pattern(K0, St0), + {V,St2} = pattern(V0, St1), + {{map_field_assoc,Line,K,V},St2}; %%pattern({struct,Line,Tag,Ps}, St0) -> %% {TPs,TPsvs,St1} = pattern_list(Ps, St0), %% {{tuple,Line,[{atom,Line,Tag}|TPs]},TPsvs,St1}; |