Skip to content

Commit

Permalink
Fix panic to avoid warning message
Browse files Browse the repository at this point in the history
This avoids the following error message on gleam v1.2.1.

```
warning: Panic used as a function
  ┌─ /Users/kevinrobell/Desktop/other/Coding/Projects/persistent_regex/bench/build/packages/gleamy_bench/src/gleamy/bench.gleam:9:9
  │
9 │   panic("not implemented")
  │         ^^^^^^^^^^^^^^^^^

`panic` is not a function and will crash before it can do anything with
this argument.

Hint: if you want to display an error message you should write
`panic as "my error message"`
See: https://tour.gleam.run/advanced-features/panic/
```

The other changes are just because `gleam format` now sorts imports alphabetically.
  • Loading branch information
apainintheneck committed Jul 8, 2024
1 parent 7d2957c commit 7a70628
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/gleamy/bench.gleam
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import gleam/int
import gleam/float
import gleam/int
import gleam/io
import gleam/list
import gleam/string
import gleam/io

@external(erlang, "os", "perf_counter")
fn perf_counter(_resolution: Int) -> Int {
panic("not implemented")
panic as "not implemented"
}

/// timestamp in milliseconds
Expand Down
4 changes: 2 additions & 2 deletions src/gleamy_bench_example.gleam
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gleamy/bench
import gleam/io
import gleam/int
import gleam/io
import gleam/list
import gleamy/bench

fn sort_int(data) {
list.sort(data, int.compare)
Expand Down

0 comments on commit 7a70628

Please sign in to comment.