Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decoding of custom types with no fields #3

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

giacomocavalieri
Copy link
Contributor

@giacomocavalieri giacomocavalieri commented Apr 6, 2024

The decoder for custom types on the Erlang side didn't take into account variants with no fields: variants with fields are encoded as a tuple {variant_name, field_1, ..., field_n}; however, variants with no fields are encoded as a single atom: variant_name.

In my previous implementation I only checked is_tuple and didn't take into account that even a single atom could be a valid variant.
I've added the missing case and a regression test!

This PR closes #2

@MystPi
Copy link
Owner

MystPi commented Apr 6, 2024

You rock! 😍

@MystPi MystPi merged commit 8f7b16e into MystPi:master Apr 6, 2024
1 check passed
@giacomocavalieri giacomocavalieri deleted the fix-2 branch April 6, 2024 12:49
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.

Decoder decodes custom types with no fields as foreign types on the Erlang target
2 participants