Skip to content

Tracking: Call type checking #661

@onbjerg

Description

@onbjerg

Describe the feature

Tracking issue to capture all variants of type checking for ExprKind::Call here:

hir::ExprKind::Call(callee, ref args, ref _opts) => {
let mut callee_ty = self.check_expr(callee);
// Get the function type for struct constructors.
if let TyKind::Type(struct_ty) = callee_ty.kind
&& let TyKind::Struct(id) = struct_ty.kind
{
callee_ty = struct_constructor(self.gcx, struct_ty, id);
}
// TODO: `array.push() = x;` is the only valid call lvalue
let is_array_push = false;
let ty = match callee_ty.kind {
TyKind::FnPtr(_f) => {
// dbg!(callee_ty);
todo!()
}
TyKind::Type(to) => self.check_explicit_cast(expr.span, to, args),
TyKind::Event(..) | TyKind::Error(..) => {
// return callee_ty
todo!()
}
TyKind::Err(_) => callee_ty,
_ => {
let msg =
format!("expected function, found `{}`", callee_ty.display(self.gcx));
let mut err = self.dcx().err(msg).span(callee.span);
err = err.span_note(expr.span, "call expression requires function");
self.gcx.mk_ty_err(err.emit())
}
};

Refer to the parent tracking issue for guidance on working on the typechecker.

Additional context

No response

Sub-issues

Metadata

Metadata

Assignees

Labels

A-semaArea: semantic analysisC-tracking-issueCategory: an issue that collects information about a broad development initiative

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions