@@ -950,6 +950,37 @@ void smv_typecheckt::typecheck_expr_rec(exprt &expr, modet mode)
950950 // only get added by type checker
951951 PRECONDITION (false );
952952 }
953+ else if (expr.id () == ID_smv_union)
954+ {
955+ auto &lhs = to_binary_expr (expr).lhs ();
956+ auto &rhs = to_binary_expr (expr).rhs ();
957+
958+ typecheck_expr_rec (lhs, mode);
959+ typecheck_expr_rec (rhs, mode);
960+
961+ // create smv_set expression
962+ exprt::operandst elements;
963+
964+ if (lhs.id () == ID_smv_set)
965+ {
966+ elements.insert (
967+ elements.end (), lhs.operands ().begin (), lhs.operands ().end ());
968+ }
969+ else
970+ elements.push_back (lhs);
971+
972+ if (rhs.id () == ID_smv_set)
973+ {
974+ elements.insert (
975+ elements.end (), rhs.operands ().begin (), rhs.operands ().end ());
976+ }
977+ else
978+ elements.push_back (rhs);
979+
980+ expr.id (ID_smv_set);
981+ expr.operands () = std::move (elements);
982+ expr.type () = typet{ID_smv_set};
983+ }
953984 else if (expr.id () == ID_smv_setin)
954985 {
955986 auto &lhs = to_binary_expr (expr).lhs ();
@@ -1719,23 +1750,6 @@ void smv_typecheckt::convert(exprt &expr, expr_modet expr_mode)
17191750 expr.id (ID_next_symbol);
17201751 }
17211752 }
1722- else if (expr.id ()==" smv_nondet_choice" ||
1723- expr.id ()==" smv_union" )
1724- {
1725- if (expr.operands ().size ()==0 )
1726- {
1727- throw errort ().with_location (expr.find_source_location ())
1728- << " expected operand here" ;
1729- }
1730-
1731- std::string identifier=
1732- module +" ::var::" +std::to_string (nondet_count++);
1733-
1734- expr.set (ID_identifier, identifier);
1735- expr.set (" #smv_nondet_choice" , true );
1736-
1737- expr.id (ID_constraint_select_one);
1738- }
17391753 else if (expr.id ()==" smv_cases" ) // cases
17401754 {
17411755 if (expr.operands ().size ()<1 )
0 commit comments