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

BitArray syntax badarg runtime error #3652

Open
schurhammer opened this issue Sep 27, 2024 · 1 comment
Open

BitArray syntax badarg runtime error #3652

schurhammer opened this issue Sep 27, 2024 · 1 comment
Labels
discussion The approach has not yet been decided

Comments

@schurhammer
Copy link
Contributor

Just creating an issue to discuss this, there might not be much we can or should do about it.

Basically the bitarray syntax allows you to read more bits than is in the bit array, leading to a runtime error.

let a = <<1, 2, 3>>
let b = <<a:32-bits>>
erlang:error(Badarg)

If this was an integer instead of a bit array, it would be zero padded. Maybe we could do that.

@schurhammer schurhammer added the bug Something isn't working label Sep 27, 2024
@lpil
Copy link
Member

lpil commented Sep 28, 2024

We could statically reject the specific case of <<a:32-bits>> as we can tell the size is longer than the array?

What code would we generate if we were to pad it?

@lpil lpil added discussion The approach has not yet been decided and removed bug Something isn't working labels Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion The approach has not yet been decided
Projects
None yet
Development

No branches or pull requests

2 participants