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

Invalid Erlang generated for pipe expression in bit array size segment #3944

Open
richard-viney opened this issue Dec 3, 2024 · 1 comment
Labels
bug Something isn't working help wanted Contributions encouraged priority:medium

Comments

@richard-viney
Copy link
Contributor

This Gleam code that uses a pipe in a size bit array segment:

pub fn main() {
  <<<<0xAE>>:bits-size(5 |> identity)>>
}

fn identity(x) {
  x
}

Produces this error output from gleam build on Gleam 1.6.2:

  Compiling bit_array_test
/Users/richardviney/Code/bit_array_test/src/bit_array_test.gleam:8:39: syntax error before: ','
/Users/richardviney/Code/bit_array_test/build/dev/erlang/bit_array_test/_gleam_artefacts/bit_array_test.erl:4:2: function main/0 undefined
%    4| -export([main/0]).
%     |  ^

/Users/richardviney/Code/bit_array_test/src/bit_array_test.gleam:6:2: spec for undefined function main/0
%    6|   <<<<0xAE>>:bits-size(5 |> identity)>>
%     |  ^

error: Shell command failure

There was a problem when running the shell command `escript`.

The generated Erlang code is here: bit_array_test.erl.txt


I'm uncertain whether pipes in bit array segments are meant to work, but blocks and case expressions work so pipes probably should too.

@richard-viney richard-viney added the bug Something isn't working label Dec 3, 2024
@lpil
Copy link
Member

lpil commented Dec 3, 2024

Ah! Yes, this is a bug. It should work and not generate invalid Erlang here.

@lpil lpil added help wanted Contributions encouraged priority:medium labels Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Contributions encouraged priority:medium
Projects
None yet
Development

No branches or pull requests

2 participants