Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
5621-Fix-compiler-crash-for-literal-map-generat...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 5621-Fix-compiler-crash-for-literal-map-generator-pattern.patch of Package erlang
From 58cab53aa9c369cda8f1089676c35ed57bda1538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Mon, 6 Feb 2023 13:12:10 +0100 Subject: [PATCH] Fix compiler crash for literal map generator patterns --- lib/compiler/src/v3_core.erl | 10 ++++++---- lib/compiler/test/mc_SUITE.erl | 9 +++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/compiler/src/v3_core.erl b/lib/compiler/src/v3_core.erl index cedb162eef..8e0ba6ae26 100644 --- a/lib/compiler/src/v3_core.erl +++ b/lib/compiler/src/v3_core.erl @@ -87,7 +87,7 @@ -import(ordsets, [add_element/2,del_element/2,is_element/2, union/1,union/2,intersection/2,subtract/2]). -import(cerl, [ann_c_cons/3,ann_c_tuple/2,c_tuple/1, - ann_c_map/3]). + ann_c_map/3,cons_hd/1,cons_tl/1]). -include("core_parse.hrl"). @@ -1932,10 +1932,12 @@ generator(Line, {m_generate,Lg,{map_field_exact,_,K0,V0},E}, Gs, St0) -> {Cg,St3} = lc_guard_tests(Gs, St2), {Ce,Pre0,St4} = safe(E, St3), AccPat = case Pat of - #c_cons{hd=K,tl=V} -> - #c_tuple{es=[K,V,IterVar]}; nomatch -> - nomatch + nomatch; + _ -> + K = cons_hd(Pat), + V = cons_tl(Pat), + #c_tuple{es=[K,V,IterVar]} end, SkipPat = #c_tuple{es=[SkipK,SkipV,IterVar]}, diff --git a/lib/compiler/test/mc_SUITE.erl b/lib/compiler/test/mc_SUITE.erl index 21aa2c017e..9da2b44479 100644 --- a/lib/compiler/test/mc_SUITE.erl +++ b/lib/compiler/test/mc_SUITE.erl @@ -97,6 +97,15 @@ basic(_Config) -> [1] = [H || {_,_} := [H|_] <- Map], [c, {b,42}] = lists:sort([K || K := [_|_] <- Map]), + %% Filtering using literal patterns. + [] = [0 || a := b <- #{}], + [] = [0 || a := b <- #{x => y}], + [0] = [0 || a := b <- #{a => b}], + + <<>> = << <<0>> || a := b <- #{} >>, + <<>> = << <<0>> || a := b <- #{x => y} >>, + <<0>> = << <<0>> || a := b <- #{a => b} >>, + ok. mc_double(Size) -> -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor