Skip to content

Using use together with pattern matches compiles, when it shouldn't #3879

Closed
@sbergen

Description

@sbergen

The following code compiles, when it shouldn't:

import gleam/io
import gleam/result

pub fn main() {
  use <<var:8>> <- result.try(wibble())
  Ok(io.debug(var))
}

fn wibble() -> Result(BitArray, Nil) {
  Ok(<<42, 0>>)
}

On Erlang, it will result in a runtime error, while on JS, it will just print 42.

Gleam version 1.6.1

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions