stage2: builtin @as

This commit is contained in:
pfg 2020-07-04 02:27:12 -07:00
parent 1d52438bd5
commit d4456d92f5
2 changed files with 7 additions and 1 deletions

View File

@ -1534,7 +1534,12 @@ fn astGenBuiltinCall(self: *Module, scope: *Scope, call: *ast.Node.BuiltinCall)
const arg_count: ?usize = if (positionals.fields[0].field_type == []*zir.Inst) null else positionals.fields.len;
if (arg_count) |some| {
if (call.params_len != some) {
return self.failTok(scope, call.builtin_token, "expected {} parameter, found {}", .{ some, call.params_len });
return self.failTok(
scope,
call.builtin_token,
"expected {} parameter{}, found {}",
.{ some, if (some == 1) "" else "s", call.params_len },
);
}
const params = call.params();
inline for (positionals.fields) |p, i| {

View File

@ -290,6 +290,7 @@ pub const Inst = struct {
pub const As = struct {
pub const base_tag = Tag.as;
pub const builtin_name = "@as";
base: Inst,
positionals: struct {