asn2wrs: Don't add an ignored constraint to a UNION

If there are UNIONS involving constraint types we currently ignore,
e.g. WITH COMPONENT[S], don't create a union involving a None, just
collapse into the other operand.

Related to #19886, #19368
This commit is contained in:
John Thacker 2024-09-02 09:57:13 -04:00
parent 6d9d3d8b99
commit dc6ff72a0c

View File

@ -6805,7 +6805,14 @@ def p_Unions_1 (t):
def p_Unions_2 (t):
'Unions : UElems UnionMark Intersections'
t[0] = Constraint(type = 'Union', subtype = [t[1], t[3]])
# Constraints currently ignored become None, e.g. InnerTypeConstraints
# (WITH COMPONENT[S]). Don't add them to a Union.
if t[3] is None:
t[0] = t[1]
elif t[1] is None:
t[0] = t[3]
else:
t[0] = Constraint(type = 'Union', subtype = [t[1], t[3]])
def p_UElems (t):
'UElems : Unions'