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

Bit array slices of slices incorrect on JavaScript #595

Closed
richard-viney opened this issue May 19, 2024 · 0 comments · Fixed by #596
Closed

Bit array slices of slices incorrect on JavaScript #595

richard-viney opened this issue May 19, 2024 · 0 comments · Fixed by #596

Comments

@richard-viney
Copy link
Contributor

If you create a bit array, slice it with a non-zero offset, and then slice the resulting bit array again, the result is incorrect on the JavaScript target:

import gleam/bit_array
import gleam/io

pub fn main() {
  let a = <<0x41, 0x5A>>
  io.println(bit_array.inspect(a))

  let assert Ok(b) = bit_array.slice(a, 1, 1)
  io.println(bit_array.inspect(b))

  let assert Ok(c) = bit_array.slice(b, 0, 1)
  io.println(bit_array.inspect(c))
}

Correct output on Erlang:

<<65, 90>>
<<90>>
<<90>>

Incorrect output on JavaScript:

<<65, 90>>
<<90>>
<<65>>

A small PR will follow shortly that fixes the issue.

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 a pull request may close this issue.

1 participant