else
{
HirId size_id = type.get_size_expr ().get_mappings ().get_hirid ();
- unify_site (size_id, TyTy::TyWithLocation (expected_ty),
- TyTy::TyWithLocation (capacity_type,
- type.get_size_expr ().get_locus ()),
- type.get_size_expr ().get_locus ());
+ TyTy::BaseType *result
+ = unify_site (size_id, TyTy::TyWithLocation (expected_ty),
+ TyTy::TyWithLocation (capacity_type,
+ type.get_size_expr ().get_locus ()),
+ type.get_size_expr ().get_locus ());
- auto ctx = Compile::Context::get ();
- tree capacity_expr = Compile::HIRCompileBase::query_compile_const_expr (
- ctx, capacity_type, type.get_size_expr ());
-
- const_type = new TyTy::ConstType (TyTy::ConstType::ConstKind::Value, "",
- expected_ty, capacity_expr, {},
- type.get_size_expr ().get_locus (),
- size_id, size_id);
+ if (result->is<TyTy::ErrorType> ())
+ {
+ const_type
+ = new TyTy::ConstType (TyTy::ConstType::ConstKind::Error, "",
+ expected_ty, error_mark_node, {},
+ type.get_size_expr ().get_locus (), size_id,
+ size_id);
+ }
+ else
+ {
+ auto ctx = Compile::Context::get ();
+ tree capacity_expr
+ = Compile::HIRCompileBase::query_compile_const_expr (
+ ctx, capacity_type, type.get_size_expr ());
+
+ const_type = new TyTy::ConstType (TyTy::ConstType::ConstKind::Value,
+ "", expected_ty, capacity_expr, {},
+ type.get_size_expr ().get_locus (),
+ size_id, size_id);
+ }
}
translated
--- /dev/null
+const fn add(x: usize, y: usize) -> i32 {
+ add + y
+ // { dg-error "cannot apply operator .+. to types fn .x usize,y usize,. -> i32 and usize" "" { target *-*-* } .-1 }
+}
+const ARR: [i32; add(1, 2)] = [5, 6, 1];
+// { dg-error "mismatched types, expected .usize. but got .i32. .E0308." "" { target *-*-* } .-1 }
+// { dg-error "mismatched types" "" { target *-*-* } .-2 }