Skip to content

Commit 2c27b41

Browse files
Assertion to forbid calling json() with nil values
json() does not deal with nil expression and would just give "name" : "unknown". On the other hand nil expression should not make it to that stage so it would probably denotes an error.
1 parent b0b8bbc commit 2c27b41

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/goto-programs/json_goto_trace.cpp

+6-11
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,8 @@ void convert(
9292
std::string value_string, binary_string, type_string, full_lhs_string;
9393
json_objectt full_lhs_value;
9494

95-
if(step.full_lhs.is_not_nil())
96-
full_lhs_string=from_expr(ns, identifier, step.full_lhs);
97-
98-
#if 0
99-
if(it.full_lhs_value.is_not_nil())
100-
full_lhs_value_string=from_expr(ns, identifier, it.full_lhs_value);
101-
#endif
95+
assert(step.full_lhs.is_not_nil());
96+
full_lhs_string=from_expr(ns, identifier, step.full_lhs);
10297

10398
const symbolt *symbol;
10499
irep_idt base_name, display_name;
@@ -111,13 +106,13 @@ void convert(
111106
type_string=from_type(ns, identifier, symbol->type);
112107

113108
json_assignment["mode"]=json_stringt(id2string(symbol->mode));
114-
if(step.full_lhs_value.is_not_nil())
115-
full_lhs_value=json(step.full_lhs_value, ns, symbol->mode);
109+
assert(step.full_lhs_value.is_not_nil());
110+
full_lhs_value=json(step.full_lhs_value, ns, symbol->mode);
116111
}
117112
else
118113
{
119-
if(step.full_lhs_value.is_not_nil())
120-
full_lhs_value=json(step.full_lhs_value, ns);
114+
assert(step.full_lhs_value.is_not_nil());
115+
full_lhs_value=json(step.full_lhs_value, ns);
121116
}
122117

123118
json_assignment["value"]=full_lhs_value;

0 commit comments

Comments
 (0)