Skip to content

COMPONENTS OF inserts contained elements in the wrong order #115

Open
@thequux

Description

@thequux

Given the source

TestDefs { joint-iso-itu-t 1 3 6 1 4 1 33827 1 }
DEFINITIONS ::=
BEGIN

SeqA ::= SEQUENCE {
    aa	[1] INTEGER,
    ab	[2] INTEGER
}

SeqB ::= SEQUENCE {
    ba	[3] INTEGER,
    COMPONENTS OF SeqA,
    bb	[4] INTEGER
}

END

rasn-compiler generates SeqB as

    #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
    pub struct SeqB {
        #[rasn(tag(context, 3))]
        pub ba: Integer,
        #[rasn(tag(context, 4))]
        pub bb: Integer,
        #[rasn(tag(context, 1))]
        pub aa: Integer,
        #[rasn(tag(context, 2))]
        pub ab: Integer,
    }

According to X.680-2021,

25.5 "Type" in the "COMPONENTS OF Type" notation shall be a sequence type. The "COMPONENTS OF Type" notation shall be used to define the inclusion, at this point in the list of components, of all the component types (of which there shall be at least one) of the referenced type, except for any extension marker and extension additions that may be present in the "Type".

Therefore, the code that should have been generated is as follows

    #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
    pub struct SeqB {
        #[rasn(tag(context, 3))]
        pub ba: Integer,
        #[rasn(tag(context, 1))]
        pub aa: Integer,
        #[rasn(tag(context, 2))]
        pub ab: Integer,
        #[rasn(tag(context, 4))]
        pub bb: Integer,
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions