AtomVM
AtomVM copied to clipboard
Support matching bitstrings that are in fact binaries (size divisible by 8)
In some cases, there's generic code that uses the bitstring modifier because it needs to work for both bitstrings and binaries, for example in erl_eval. Currently such code doesn't work even if no actual bitstrings are involved, and this PR attempts to fix it. In other words, this now works:
defmodule Foo do
def pattern_match(x, s) do
case x do
<<a::bitstring-size(s), b::bitstring>> ->
{a, b}
_ ->
:no_match
end
end
end
Foo.pattern_match(<<234, 123, 2>>, 16)
# => {<<234, 123>>, <<2>>}
TODO:
- [x] add tests
- [x] adjust
jit.erl