aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/asn1/src/asn1ct_check.erl9
-rw-r--r--lib/asn1/src/asn1ct_parser2.erl10
-rw-r--r--lib/asn1/test/error_SUITE.erl7
3 files changed, 16 insertions, 10 deletions
diff --git a/lib/asn1/src/asn1ct_check.erl b/lib/asn1/src/asn1ct_check.erl
index 4ff8a414fb..7ed7da2ae7 100644
--- a/lib/asn1/src/asn1ct_check.erl
+++ b/lib/asn1/src/asn1ct_check.erl
@@ -585,6 +585,12 @@ check_class_fields(S,[F|Fields],Acc) ->
case element(1,F) of
fixedtypevaluefield ->
{_,Name,Type,Unique,OSpec} = F,
+ case {Unique,OSpec} of
+ {'UNIQUE',{'DEFAULT',_}} ->
+ asn1_error(S, {unique_and_default,Name});
+ {_,_} ->
+ ok
+ end,
RefType = check_type(S,#typedef{typespec=Type},Type),
{fixedtypevaluefield,Name,RefType,Unique,OSpec};
object_or_fixedtypevalue_field ->
@@ -5898,6 +5904,9 @@ format_error({undefined_field,FieldName}) ->
io_lib:format("the field '&~s' is undefined", [FieldName]);
format_error({undefined_import,Ref,Module}) ->
io_lib:format("'~s' is not exported from ~s", [Ref,Module]);
+format_error({unique_and_default,Field}) ->
+ io_lib:format("the field '&~s' must not have both 'UNIQUE' and 'DEFAULT'",
+ [Field]);
format_error({value_reused,Val}) ->
io_lib:format("the value '~p' is used more than once", [Val]);
format_error({non_unique_object,Id}) ->
diff --git a/lib/asn1/src/asn1ct_parser2.erl b/lib/asn1/src/asn1ct_parser2.erl
index c19811ea49..3960498742 100644
--- a/lib/asn1/src/asn1ct_parser2.erl
+++ b/lib/asn1/src/asn1ct_parser2.erl
@@ -1111,14 +1111,8 @@ parse_FixedTypeValueFieldSpec([{valuefieldreference,L1,VFieldName}|Rest]) ->
{OptionalitySpec,Rest5} = parse_ValueOptionalitySpec(Rest3),
case {Unique,Rest5} of
{'UNIQUE',[{Del,_}|_]} when Del =:= ','; Del =:= '}' ->
- case OptionalitySpec of
- {'DEFAULT',_} ->
- throw({asn1_error,
- {L1,get(asn1_module),
- ['UNIQUE and DEFAULT in same field',VFieldName]}});
- _ ->
- {{fixedtypevaluefield,VFieldName,Type,Unique,OptionalitySpec},Rest5}
- end;
+ {{fixedtypevaluefield,VFieldName,Type,Unique,
+ OptionalitySpec},Rest5};
{_,[{Del,_}|_]} when Del =:= ','; Del =:= '}' ->
{{object_or_fixedtypevalue_field,VFieldName,Type,Unique,OptionalitySpec},Rest5};
_ ->
diff --git a/lib/asn1/test/error_SUITE.erl b/lib/asn1/test/error_SUITE.erl
index fc5f2dfe43..331d3607af 100644
--- a/lib/asn1/test/error_SUITE.erl
+++ b/lib/asn1/test/error_SUITE.erl
@@ -112,10 +112,13 @@ classes(Config) ->
P = {M,
<<"Classes DEFINITIONS AUTOMATIC TAGS ::= BEGIN\n"
" LowerCase ::= CLASS { &id INTEGER UNIQUE }\n"
+ " CL ::= CLASS { &id INTEGER UNIQUE DEFAULT 42}\n"
"END\n">>},
{error,
- [{structured_error,{M,2},asn1ct_check,{illegal_class_name,
- 'LowerCase'}}
+ [{structured_error,{M,2},asn1ct_check,
+ {illegal_class_name,'LowerCase'}},
+ {structured_error,{M,3},asn1ct_check,
+ {unique_and_default,id}}
]} = run(P, Config),
ok.