Closed Neilerino closed 1 month ago
Thank you
Looks like this only occurs if you're using a constant, since the value is essentially inlined, and I guess erlang doesn't like functions in guard clauses, even if they aren't being called. Probably the easiest fix for this would be to assign the value to a temporary variable beforehand and just do the case on that. The equivalent of (this compiles):
// test_gleam.gleam
import gleam/io
import other_file
pub fn main() {
let case_var = ["test", "test2"]
let temp = other_file.case_test
case case_var {
[head, ..] if head == temp.input_string -> {
io.println("test")
}
_ -> {
io.println("not test")
}
}
}
Also, I believe this is the same issue as #3069
Thank you @GearsDatapacks !
Bumped into this case in a project I was working on last night. If I try to use a record which includes a function as a parameter I get an erlang compilation error. Running with latest release of gleam. Here's my basic repro steps:
gleam run
output snippet with trace logging enabled:If I remove the function from the records params like this, I'm able to compile and run without issues.