aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_check.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-12-05 12:07:10 +0100
committerBjörn Gustavsson <[email protected]>2015-01-12 12:22:56 +0100
commit831b45783976886675f853bca8a9a75ec39cda5c (patch)
tree6cac0f80023b4308cf129270c08d8b37737a15d8 /lib/asn1/src/asn1ct_check.erl
parent7d390a1ec41268978fbd9ad3727392ad569e8d24 (diff)
downloadotp-831b45783976886675f853bca8a9a75ec39cda5c.tar.gz
otp-831b45783976886675f853bca8a9a75ec39cda5c.tar.bz2
otp-831b45783976886675f853bca8a9a75ec39cda5c.zip
Move checking of UNIQUE & DEFAULT error to asn1ct_check
To keep the error reporting code in asn1ct_parser2 simple, we only want to handle pure syntactic errors. Therefore, move the check that UNIQUE and DEFAULT are not applied to the same field to asn1ct_check.
Diffstat (limited to 'lib/asn1/src/asn1ct_check.erl')
-rw-r--r--lib/asn1/src/asn1ct_check.erl9
1 files changed, 9 insertions, 0 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}) ->