Skip to content

Don't derive Eq for types that contain REAL - #145

Merged
gabhijit merged 2 commits into
ystero-dev:masterfrom
rizwan3659:skip-eq-for-real
Sep 24, 2026
Merged

gabhijit merged 2 commits into
ystero-dev:masterfrom
rizwan3659:skip-eq-for-real

Conversation

@rizwan3659

Copy link
Copy Markdown

REAL is generated as f64, which is only PartialEq. Right now the same derive list goes on every type, so asking for Eq breaks the build for any spec that has a REAL in it (E2SM-KPM, for example).

This change collects all types that contain a REAL before generating code: directly, inside a SEQUENCE / CHOICE / SEQUENCE OF / open type, or through a reference to another such type. It keeps going over the types until nothing new is found, so chains of references are handled too. Eq is left out only for those types. Everything else still gets it, so specs without REAL generate the same code as before.

I added a test that compiles a small module with Eq enabled and checks the derives on each generated type.

Fixes #110

gabhijit
gabhijit previously approved these changes Sep 23, 2026

@gabhijit gabhijit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR looks good for a couple of comments that I have added. Better to warn! for the types where the Eq derive was skipped, when the user has asked for it.

Also, it might be a good idea to squash these into fewer related commits.

Comment thread asn-compiler/src/generator/int.rs
Comment thread asn-compiler/src/generator/int.rs
rizwan alam added 2 commits September 23, 2026 16:37
f64 is only PartialEq, so deriving Eq on a type that has a REAL in it
(directly, inside a SEQUENCE / CHOICE / SEQUENCE OF / open type, or
through references to other such types) breaks the generated code.
Collect those types before generating and leave Eq out for them. A
warning is logged for each type where Eq was asked for but skipped.

Fixes ystero-dev#110

Signed-off-by: rizwan alam <akaify@cdot.in>
Signed-off-by: rizwan alam <akaify@cdot.in>
@rizwan3659

Copy link
Copy Markdown
Author

@gabhijit Thanks for the review! Addressed both comments:

  • Added a warn! that names the type whenever Eq was asked for but skipped because the type contains a REAL.
  • Squashed the commits into two (generator change + test).

@gabhijit
gabhijit merged commit ee6fa3e into ystero-dev:master Sep 24, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ASN.1 compiler deriving Eq support for ASN.1 REAL values causes Rust compiler errors

2 participants