-
Notifications
You must be signed in to change notification settings - Fork 21
Description
The handling of IMPORTS fails to compile when importing a name from a module that's already defined in the current module. This is because the current compile_text() only supports one module entry per name in the _imp_ dict (keyed on name).
ITU-T X.680 supports the same name imported from multiple places as well as being defined locally, as long as the imported types are fully qualified. See When importing modules in ASN files, how do we get those modules or set it up for import?
I have a local fix to change the _imp_ handling from dict{name : module} to dict{name : list(module)}. This resolves problems I had when compiling some complex modules with many IMPORTS that also import back to the original modules, including:
- Importing a name that's also defined locally.
- Using an imported name without the module qualifier when the name is only defined by that module.
I'll submit a pull request with the fixes, including adding test cases to exercise the faulty code before fixing it.
An example module that fails is below:
BaseModule DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
IMPORTS
ConflictSeq,
Imp1Int
FROM ImportModule1
ConflictSeq,
Imp2Str
FROM ImportModule2
;
Seq ::= SEQUENCE
{
seqint [1] INTEGER,
basecs [2] ConflictSeq,
imp1cs [3] ImportModule1.ConflictSeq,
imp1int [4] Imp1Int,
imp2cs [5] ImportModule2.ConflictSeq,
imp2str [6] Imp2Str,
last [7] BOOLEAN
}
-- ConflictSeq is also defined in imported modules
ConflictSeq ::= SEQUENCE
{
bcsint [1] INTEGER
}
END
--
-- ImportModule1
--
ImportModule1 DEFINITIONS AUTOMATIC TAGS ::=
IMPORTS
Imp2Str FROM ImportModule2
;
BEGIN
Imp1Int ::= INTEGER
Imp1Str ::= ImportModule2.Imp2Str
ConflictSeq ::= SEQUENCE
{
i1int [1] INTEGER
}
END
--
-- ImportModule2
--
ImportModule2 DEFINITIONS AUTOMATIC TAGS ::=
BEGIN
Imp2Str ::= OCTET STRING (SIZE(0..7))
ConflictSeq ::= SEQUENCE
{
i2str [1] OCTET STRING
}
END