Skip to content

Commit

Permalink
Merge pull request #7575 from bjorng/bjorn/asn1/constraints/OTP-18729
Browse files Browse the repository at this point in the history
asn1: Fix handling of SIZE constraints
  • Loading branch information
bjorng authored Aug 21, 2023
2 parents 0db74ed + 6b098b7 commit f5c45b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/asn1/src/asn1ct_check.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3559,6 +3559,20 @@ range_union_1([]) ->
finish_constraints(Cs) ->
finish_constraints_1(Cs, fun smart_collapse/1).

finish_constraints_1([{element_set,{'SizeConstraint',
{element_set,Root,none}},
{set,[]}=Set}|T],
Collapse) ->
%% Rewrite:
%%
%% (SIZE (Lower..Upper), ...)
%%
%% to:
%%
%% (SIZE (Lower..Upper, ...))

C = {element_set,{'SizeConstraint',{element_set,Root,Set}},none},
finish_constraints_1([C|T], Collapse);
finish_constraints_1([{element_set,{Tag,{element_set,_,_}=Set0},none}|T],
Collapse0) ->
Collapse = collapse_fun(Tag),
Expand Down
2 changes: 2 additions & 0 deletions lib/asn1/test/asn1_SUITE_data/ConstraintEquivalence.asn1
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ BEGIN
ExtConstrainedStringX04 ::= IA5String (SIZE (1|2), ..., SIZE (1|2|3|4|5))
ExtConstrainedStringX05 ::= IA5String (SIZE (1|2, ...), ...,
SIZE (1|2|3|4|5, ...))
-- The following syntax is not recommended, but should work.
ExtConstrainedStringX06 ::= IA5String (SIZE (1..2), ...)

integer4 INTEGER ::= 4
integer11 INTEGER ::= 11
Expand Down

0 comments on commit f5c45b6

Please sign in to comment.