Skip to content

Error Compiling when Having Multiple Size Constraints #59

@zhouxt1

Description

@zhouxt1

Hi,
I encountered this issue when compiling ETSI-ITS-CDD. I got another error different than #41.

File "/pycrate/tools/pycrate_asn1compile.py", line 215, in main
    compile_text(txt, **ckw)
    ~~~~~~~~~~~~^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.13/site-packages/pycrate_asn1c/asnproc.py", line 287, in compile_text
    verify_modules(**kwargs)
    ~~~~~~~~~~~~~~^^^^^^^^^^
  File "/opt/homebrew/lib/python3.13/site-packages/pycrate_asn1c/asnproc.py", line 1074, in verify_modules
    S = reduce_setdicts(consts)
  File "/opt/homebrew/lib/python3.13/site-packages/pycrate_asn1c/setobj.py", line 842, in reduce_setdicts
    return reduce_sets([ASN1Set(sd) for sd in sdl])
  File "/opt/homebrew/lib/python3.13/site-packages/pycrate_asn1c/setobj.py", line 850, in reduce_sets
    return reduce(lambda a, b: a.intersect(b), sl[::-1])
  File "/opt/homebrew/lib/python3.13/site-packages/pycrate_asn1c/setobj.py", line 850, in <lambda>
    return reduce(lambda a, b: a.intersect(b), sl[::-1])
                               ~~~~~~~~~~~^^^
  File "/opt/homebrew/lib/python3.13/site-packages/pycrate_asn1c/setobj.py", line 799, in intersect
    ret._init()
    ~~~~~~~~~^^
  File "/opt/homebrew/lib/python3.13/site-packages/pycrate_asn1c/setobj.py", line 691, in _init
    if ev[ev_off] < er[er_off]:
       ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'ASN1RangeInt' and 'int.'

I found that the message causing the issue is the following:

PolygonalShape ::= SEQUENCE {
   shapeReferencePoint    CartesianPosition3d OPTIONAL,
   polygon                SequenceOfCartesianPosition3d (SIZE(3..16,...)),
   height                 StandardLength12b OPTIONAL
}
SequenceOfCartesianPosition3d ::= SEQUENCE (SIZE(1..16, ...)) OF CartesianPosition3d
CartesianPosition3d::=SEQUENCE{
    xCoordinate    CartesianCoordinate,
    yCoordinate    CartesianCoordinate,
    zCoordinate    CartesianCoordinate OPTIONAL
}
CartesianCoordinate::= INTEGER{
    negativeOutOfRange (-32768),
    positiveOutOfRange (32767)
} (-32768..32767)

It seems that pycrate cannot handle the additional constraint (SIZE(3..16,...)) at the polygon field in the message PolygonalShape.
If I remove that additional constraint, it would compile.

(for a minimum self-contained example, just comment out the shapeReferencePoint and height.)

Is this a known bug?

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