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

Currently bitstring segment size must be multiple of 8 when compiling to JavaScript, add compiletime check #1591

Open
CrowdHailer opened this issue Apr 14, 2022 · 2 comments · May be fixed by #3111
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:low

Comments

@CrowdHailer
Copy link
Contributor

CrowdHailer commented Apr 14, 2022

// ok
<<1:size(8)>>
<<1:size(x)>>

// not ok
<<1:size(7)>>

This won't catch all errors, because x could evaluate at runtime to a value that isn't a multiple of 8. However catching the literal cases when the term is explicitly an integer will still be valuable.

@massivefermion
Copy link
Contributor

I don't agree. Being able to manipulate bitstrings at the bit level is actually pretty useful. After doing it in elixir and gleam, I really miss it in javascript and Rust.

@CrowdHailer
Copy link
Contributor Author

This issue isn't saying don't implement bitstrings down to the bit level. it's saying while only bytes strings are supported (as is currently the case) For that time we should warn at compile time, rather than runtime when possible.

If there are suggestions in how to support bit level manipulation in JS it would be good to explore them.

@CrowdHailer CrowdHailer changed the title Bitstring segment size must be multiple of 8, add compiletime check Bitstring segment size must be multiple of 8, when compiling to JavaScript, add compiletime check Apr 15, 2022
@lpil lpil changed the title Bitstring segment size must be multiple of 8, when compiling to JavaScript, add compiletime check Currently bitstring segment size must be multiple of 8 when compiling to JavaScript, add compiletime check Apr 16, 2022
@lpil lpil added help wanted Contributions encouraged good first issue Good for newcomers area:type-analysis labels Apr 16, 2022
Pi-Cla added a commit to Pi-Cla/gleam that referenced this issue May 8, 2024
…on js

Try to detect when someone tries to make a non byte aligned array on Javascript.
This compile time error still fails to trigger if the size value is a variable though.
So we still need the runtime error in the Javascript template too.

Fixes gleam-lang#1591
Pi-Cla added a commit to Pi-Cla/gleam that referenced this issue May 8, 2024
…on js

Try to detect when someone tries to make a non byte aligned array on Javascript.
This compile time error still fails to trigger if the size value is a variable though.
So we still need the runtime error in the Javascript template too.

Fixes gleam-lang#1591
Pi-Cla added a commit to Pi-Cla/gleam that referenced this issue May 10, 2024
…on js

Try to detect when someone tries to make a non byte aligned array on Javascript.
This compile time error still fails to trigger if the size value is a variable though.
So we still need the runtime error in the Javascript template too.

Fixes gleam-lang#1591
Pi-Cla added a commit to Pi-Cla/gleam that referenced this issue May 10, 2024
…on js

Try to detect when someone tries to make a non byte aligned array on Javascript.
This compile time error still fails to trigger if the size value is a variable though.
So we still need the runtime error in the Javascript template too.

Fixes gleam-lang#1591
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Contributions encouraged priority:low
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants