Skip to content

Compiler panic in byte_string::decode() when hex escape contains multi-byte UTF-8 character #25775

@jubnzv

Description

@jubnzv

The compiler panics with unreachable!() in expansion/byte_string.rs:165 when a byte string hex escape (\xNN) contains a multi-byte UTF-8 character as one of its hex digits.

Root cause: decode_() collects two characters after \x and passes the resulting String to hex::decode(). When one character is multi-byte (e.g. ñ = 2 bytes UTF-8), the string has an odd byte count which leads to the unreachable() execution path.

MRE:

module 0x42::m {
    fun f(): vector<u8> {
        b"\xAñ"
    }
}

Reproduce steps:

cd external-crates/move
cargo +nightly run --release -p move-compiler --bin move-check -- mre/mre_byte_string_decode_165.move

Output:

thread 'main' panicked at crates/move-compiler/src/expansion/byte_string.rs:165:31:
internal error: entered unreachable code: ICE unexpected error parsing hex byte string value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior: a diagnostic error (invalid hex character), not an ICE.

Git commit: dc73efd
cargo 1.91.0-nightly (840b83a10 2025-07-30)
rustc 1.91.0-nightly (3672a55b7 2025-08-13)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions