Type Mismatch and ICE on Slice Constant Pattern Matching in gccrs
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the failure with the Rust snippet or the linked Godbolt example, then inspect the pattern type-checking path named in the backtrace, especially TypeCheckPattern::visit in rust/typecheck/rust-tyty-util.cc. Trace both the slice-constant coercion and the match-pattern handling; done means the example compiles without the type mismatch or ICE and preserves the expected slice-content match behavior.
Written by the indexing model from the issue text.
Description
Summary
The provided Rust code compiles successfully with rustc but fails with gccrs due to a type mismatch and an internal compiler error (ICE). The issues occur when initializing a slice constant and using it in a pattern match.
Reproducer
I tried this code:
#![allow(dead_code)]
const PATH_DOT: &[u8] = &[b'.'];// Type mismatch error here
fn match_slice(element: &[u8]) {
match element {
&[] => {}
PATH_DOT => {}// ICE occurs during type checking
_ => {}
}
}
fn main() {}
Does the code make use of any (1.49) nightly feature ?
- Nightly
Godbolt link
https://godbolt.org/z/8PETWKfK5
Actual behavior
:4:1: error: mismatched types, expected '& [u8]' but got '& [u8:CAPACITY]' [E0308]
4 | const PATH_DOT: &[u8] = &[b'.'];
| ^~~~~ ~ ~
:8:10: sorry, unimplemented: type checking qualified path patterns not supported
8 | &[] => {}
| ^
crab1: internal compiler error: in TyVar, at rust/typecheck/rust-tyty-util.cc:31
0x2e9eb6c internal_error(char const*, ...)
???:0
0xf5e963 fancy_abort(char const*, int, char const*)
???:0
0x12795a2 Rust::Resolver::TypeCheckPattern::visit(Rust::HIR::ReferencePattern&)
???:0
0x12793d8 Rust::Resolver::TypeCheckPattern::Resolve(Rust::HIR::Pattern*, Rust::TyTy::BaseType*)
???:0
0x127eaef Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::MatchExpr&)
???:0
0x127bd13 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr*)
???:0
0x127d11d Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::BlockExpr&)
???:0
0x127bd13 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr*)
???:0
0x126a82b Rust::Resolver::TypeCheckItem::visit(Rust::HIR::Function&)
???:0
0x1263750 Rust::Resolver::TypeCheckItem::Resolve(Rust::HIR::Item&)
???:0
0x122427b Rust::Resolver::TypeResolution::Resolve(Rust::HIR::Crate&)
???:0
0x109a454 Rust::Session::compile_crate(char const*)
???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See https://gcc.gnu.org/bugs/ for instructions.
Compiler returned: 1
Expected behavior
The code should compile successfully. The constant PATH_DOT (type &[u8]) should be initialized from &[u8; 1] via implicit array-to-slice coercion. The match arm PATH_DOT should compare slice contents structurally.
GCC Version
14.0.1
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 20h 2m
- Merged PRs (30d)
- 66
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rust-GCC/gccrs
-
core
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
method not found Opencore
-
expansion good-first-pr
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
expansion good-first-pr
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
expansion good-first-pr
Difficulty 3/5 1-2 days Newbie friendliness 55/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Sensor initialization takes very long when `--initial-sim-time` is set to current UNIX timestamp Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
gazebosim/gz-sensors#662 · 1 comment ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LadybirdBrowser/ladybird#12123 ·