gleam-lang / crypto

⛓️ Crypto functionality for Gleam applications
https://hexdocs.pm/gleam_crypto/
Apache License 2.0
36 stars 11 forks source link

Inexhaustive patterns #9

Closed Myzel394 closed 4 months ago

Myzel394 commented 5 months ago

Hey, so this is my very first time fuddling around with Gleam; I'm sorry if this is an issue on my side, but I couldn't find anything on the internet about this otherwise.

I'm following this article to run a Gleam webserver. I copied the sample code:

import gleam/erlang/process
import mist
import wisp

pub fn main() {
  wisp.configure_logger()

  let assert Ok(_) =
    wisp.mist_handler(fn(_) { todo }, "secret_key")
    |> mist.new
    |> mist.port(8000)
    |> mist.start_http

  process.sleep_forever()
}

but running gleam run shows the following error:

$ gleam run
  Compiling gleam_crypto
error: Inexhaustive patterns
   ┌─ ~/gleamtest/build/packages/gleam_crypto/src/gleam/crypto.gleam:47:3
   │
47 │ ╭   case left, right {
48 │ │     <<x, left:bits>>, <<y, right:bits>> -> {
49 │ │       let accumulator =
50 │ │         int.bitwise_or(accumulator, int.bitwise_exclusive_or(x, y))
   · │
53 │ │     <<>>, <<>> -> accumulator == 0
54 │ │   }
   │ ╰───^

This case expression does not have a pattern for all possible values.
If it is run on one of the values without a pattern then it will crash.

The missing patterns are:

    _

It looks like not all cases are matched in the gleam_crypto library

gleam version:

gleam 1.2.1
lpil commented 4 months ago

Hello! You're using quite an old version of this library, perhaps due to an outdated tight constraint of one of your dependencies. If you update deps versions (try `gleam update) then it will compile with current versions of Gleam.