[erlang-bugs] R16B02 asn1 encoding issue

Alex Peshkov <>
Thu Nov 28 14:19:38 CET 2013


Hello,

I have the ASN1 file containing the following lines:
AppConfig ::= SEQUENCE OF AppRuntimeParameter

    AppRuntimeParameter ::= CHOICE {
	debug-level INTEGER, 
	listen-port INTEGER (1..65535), 
	... 
    }

When I compile this ASN1 file with asn1ct:compile(«AppUpstream.asn1", [ber_bin, undec_rest, optimize]) and Erlang R15B01 -
I get a AppUpstream.erl file with the following code for handling ‘AppConfig’:

'enc_AppConfig'(Val) ->
    'enc_AppConfig'(Val, [<<48>>]).

'

enc_AppConfig'({‘AppConfig',Val}, TagIn) ->
   'enc_AppConfig'(Val, TagIn);

'enc_AppConfig'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_AppConfig_components'(Val,[],0),
   ?RT_BER:encode_tags(TagIn, EncBytes, EncLen).

'enc_AppConfig_components'([], AccBytes, AccLen) ->
   {lists:reverse(AccBytes),AccLen};

When I compile the same ASN1 file with asn1ct:compile(«AppUpstream.asn1", [ber, undec_rest]) and Erlang R16B02 
(the ‘optimize’ option is not necessary anymore and ‘ber_bin' is replaced with ‘ber’ according to http://www.erlang.org/doc/man/asn1ct.html) I get the following code for handling ‘AppConfig’:

'enc_AppConfig'(Val) ->
    'enc_AppConfig'(Val, [<<48>>]).

'enc_AppConfig'(Val, TagIn) ->
   {EncBytes,EncLen} = 'enc_AppConfig_components'(Val,[],0),
   encode_tags(TagIn, EncBytes, EncLen).

This part of code is omitted by erlang asn1 compiler:
'

enc_AppConfig'({‘AppConfig',Val}, TagIn) ->
   'enc_AppConfig'(Val, TagIn);

and I get function_clause error during asn1ct:encode call.


More information about the erlang-bugs mailing list