Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
1498-debugger-Fix-incorrect-evaluation-of-neste...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1498-debugger-Fix-incorrect-evaluation-of-nested-records-.patch of Package erlang
From 640339f43a743b3bc4e6533194a659fbb717a3d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Mon, 18 Mar 2024 12:43:47 +0100 Subject: [PATCH] debugger: Fix incorrect evaluation of nested records in guard Closes #8120 --- lib/debugger/src/dbg_ieval.erl | 17 +++++++++++++++++ lib/debugger/test/record_SUITE.erl | 29 +++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/lib/debugger/src/dbg_ieval.erl b/lib/debugger/src/dbg_ieval.erl index 2d736898d8..e2dc2e2d31 100644 --- a/lib/debugger/src/dbg_ieval.erl +++ b/lib/debugger/src/dbg_ieval.erl @@ -1463,6 +1463,9 @@ guard_expr({'orelse',_,E1,E2}, Bs) -> {value,_Val}=Res -> Res end end; +guard_expr({'case',_,E0,Cs}, Bs) -> + {value,E} = guard_expr(E0, Bs), + guard_case_clauses(E, Cs, Bs); guard_expr({dbg,_,self,[]}, _) -> {value,get(self)}; guard_expr({safe_bif,_,erlang,'not',As0}, Bs) -> @@ -1505,6 +1508,20 @@ guard_expr({bin,_,Flds}, Bs) -> end, [], false), {value,V}. +%% guard_case_clauses(Value, Clauses, Bindings, Error, Ieval) +%% Error = try_clause | case_clause +guard_case_clauses(Val, [{clause,_,[P],G,B}|Cs], Bs0) -> + case match(P, Val, Bs0) of + {match,Bs} -> + case guard(G, Bs) of + true -> + guard_expr(hd(B), Bs); + false -> + guard_case_clauses(Val, Cs, Bs0) + end; + nomatch -> + guard_case_clauses(Val, Cs, Bs0) + end. %% eval_map_fields([Field], Bindings, IEvalState) -> %% {[{map_assoc | map_exact,Key,Value}],Bindings} diff --git a/lib/debugger/test/record_SUITE.erl b/lib/debugger/test/record_SUITE.erl index 2f75dcda42..e3d66804bb 100644 --- a/lib/debugger/test/record_SUITE.erl +++ b/lib/debugger/test/record_SUITE.erl @@ -28,7 +28,8 @@ -export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2, init_per_testcase/2,end_per_testcase/2, init_per_suite/1,end_per_suite/1, - errors/1,record_test/1,eval_once/1]). + errors/1,record_test/1,eval_once/1, + nested_in_guard/1]). suite() -> [{ct_hooks,[ts_install_cth]}, @@ -50,7 +51,7 @@ end_per_group(_GroupName, Config) -> cases() -> - [errors, record_test, eval_once]. + [errors, record_test, eval_once, nested_in_guard]. init_per_testcase(_Case, Config) -> test_lib:interpret(?MODULE), @@ -295,4 +296,28 @@ once(Test, Record) -> end, Result. +nested_in_guard(_Config) -> + B = #bar{d = []}, + F = #foo{a = B}, + + ok = do_nested_in_guard(#foo{a=#bar{d=[]}}), + not_ok = do_nested_in_guard(#foo{a=#bar{}}), + not_ok = do_nested_in_guard(#foo{a={no_bar,a,b,c,d}}), + not_ok = do_nested_in_guard(#foo{a={bar,a}}), + not_ok = do_nested_in_guard(42), + not_ok = do_nested_in_guard(#bar{}), + not_ok = do_nested_in_guard([]), + + ok. + +-define(is_foo(X), (((X#foo.a)#bar.d == []))). + +do_nested_in_guard(F) -> + if + ?is_foo(F) -> + ok; + true -> + not_ok + end. + id(I) -> I. -- 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