fix: protocol method calls arity-check (issue 0131)
emitProtocolDispatch now requires the user-arg count to equal the protocol method's parameter list — exact, since protocol signatures have no defaults, packs, or variadics — and emits the same "expects N arguments, but M were given" diagnostic plain calls get. Previously extra args were silently dropped (and missing args left the thunk reading garbage). The dispatch gains the call-site span for the diagnostic. examples/1634 pins the rejection; full sweep confirms no existing code relied on the leniency.
This commit is contained in:
@@ -861,7 +861,7 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
|
||||
// protocol value as its first param).
|
||||
if (self.getProtocolInfo(obj_ty)) |proto_info| {
|
||||
if (protocolHasMethod(proto_info, fa.field)) {
|
||||
return self.emitProtocolDispatch(obj, proto_info, fa.field, args.items, obj_ty);
|
||||
return self.emitProtocolDispatch(obj, proto_info, fa.field, args.items, obj_ty, c.callee.span);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -878,7 +878,7 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
|
||||
const pay_ty = opt_info.optional.child;
|
||||
if (self.getProtocolInfo(pay_ty)) |proto_info| {
|
||||
if (protocolHasMethod(proto_info, fa.field)) {
|
||||
return self.emitProtocolDispatch(obj, proto_info, fa.field, args.items, pay_ty);
|
||||
return self.emitProtocolDispatch(obj, proto_info, fa.field, args.items, pay_ty, c.callee.span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user