GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: Prevent crashes on error types during type checking.

gccrs type checker now handles errors more gracefully, preventing crashes and improving reliability.

The gccrs compiler no longer crashes when encountering error types during type checking. Previously, failed expressions would result in null lookups, leading to crashes. This change ensures that error types are preserved in the context. Additionally, operators and array literals now properly bail out when an operand has already errored, preventing type stacking issues. Constants also retain their declared type if their initializer fails.

In Details

This commit addresses a crash in the gccrs type checker's expression resolution logic. When an expression failed to type-check, its error type was not propagated correctly, leading to null dereferences in subsequent lookups. The change ensures that error types are kept in the context and that operations involving errored operands or initializers bail out early, preventing cascading errors and maintaining type integrity. This impacts TypeCheckExpr::Resolve and various visitor methods within rust-hir-type-check-expr.cc and rust-hir-type-check-item.cc.

For Context
gccrs
The GCC compiler's implementation for the Rust programming language.
type checking
The process of verifying and enforcing the type constraints of a program. In compilers, it ensures that operations are applied to compatible data types.
HIR
High-level Intermediate Representation. A data structure used by compilers to represent the program's logic after initial parsing and before optimization or code generation.
AST
Abstract Syntax Tree. A tree representation of the abstract syntactic structure of source code, used by compilers to parse and analyze code.
Filed Under: gccrsrustcompilerbugfixtypechecking