Skip to content

Compiler crash when using non-UTF-8 string patterns #4530

@GearsDatapacks

Description

@GearsDatapacks

For example, with the following code:

pub fn main() {
  let assert <<"Hello":utf16, _rest:bits>> = <<"Hello, world!":utf16>>
}

If the command gleam check is run, the following error is produced:

error: Fatal compiler bug!

This is a bug in the Gleam compiler, sorry!

Please report this crash to https://github.com/gleam-lang/gleam/issues/new
and include this error message with your report.

Panic: compiler-core/src/exhaustiveness.rs:2912
        non utf8 string in bit array pattern on js target
Gleam version: 1.10.0
Operating system: linux

If you can also share your code and say what file you were editing or any
steps to reproduce the crash that would be a great help.

You may also want to try again with the `GLEAM_LOG=trace` environment
variable set.

It seems the exhaustiveness checker panics when utf16 or utf32 strings are encountered, even if it is not the javascript target. Even if it were, it should emit a compiler error, not panic.

I'm working on supporting utf16 and utf32 segments on the JS target soon, so that should fix this. Just thought I'd report it now though so we don't forget.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions