Merge pull request #11319 from Vexu/stage2-arg-count
stage2: check arg count before types
This commit is contained in:
@@ -613,7 +613,8 @@ fn addCxxKnownPath(
|
||||
ctx.cxx_compiler,
|
||||
b.fmt("-print-file-name={s}", .{objname}),
|
||||
});
|
||||
const path_unpadded = mem.tokenize(u8, path_padded, "\r\n").next().?;
|
||||
var tokenizer = mem.tokenize(u8, path_padded, "\r\n");
|
||||
const path_unpadded = tokenizer.next().?;
|
||||
if (mem.eql(u8, path_unpadded, objname)) {
|
||||
if (errtxt) |msg| {
|
||||
std.debug.print("{s}", .{msg});
|
||||
|
||||
19
src/Sema.zig
19
src/Sema.zig
@@ -2317,8 +2317,8 @@ fn zirErrorSetDecl(
|
||||
const extra_index_end = extra_index + (extra.data.fields_len * 2);
|
||||
while (extra_index < extra_index_end) : (extra_index += 2) { // +2 to skip over doc_string
|
||||
const str_index = sema.code.extra[extra_index];
|
||||
const name = try new_decl_arena_allocator.dupe(u8, sema.code.nullTerminatedString(str_index));
|
||||
const result = names.getOrPutAssumeCapacity(name);
|
||||
const kv = try sema.mod.getErrorValue(sema.code.nullTerminatedString(str_index));
|
||||
const result = names.getOrPutAssumeCapacity(kv.key);
|
||||
assert(!result.found_existing); // verified in AstGen
|
||||
}
|
||||
|
||||
@@ -3661,8 +3661,12 @@ fn zirParamType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
|
||||
fn_ty.fnInfo();
|
||||
|
||||
if (param_index >= fn_info.param_types.len) {
|
||||
assert(fn_info.is_var_args);
|
||||
return sema.addType(Type.initTag(.var_args_param));
|
||||
if (fn_info.is_var_args) {
|
||||
return sema.addType(Type.initTag(.var_args_param));
|
||||
}
|
||||
// TODO implement begin_call/end_call Zir instructions and check
|
||||
// argument count before casting arguments to parameter types.
|
||||
return sema.fail(block, callee_src, "wrong number of arguments", .{});
|
||||
}
|
||||
|
||||
if (fn_info.param_types[param_index].tag() == .generic_poison) {
|
||||
@@ -13159,11 +13163,10 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
|
||||
// TODO use reflection instead of magic numbers here
|
||||
// error_set: type,
|
||||
const name_val = struct_val[0];
|
||||
const name_str = try name_val.toAllocatedBytes(Type.initTag(.const_slice_u8), sema.arena, target);
|
||||
|
||||
names.putAssumeCapacityNoClobber(
|
||||
try name_val.toAllocatedBytes(Type.initTag(.const_slice_u8), sema.arena, target),
|
||||
{},
|
||||
);
|
||||
const kv = try sema.mod.getErrorValue(name_str);
|
||||
names.putAssumeCapacityNoClobber(kv.key, {});
|
||||
}
|
||||
|
||||
// names must be sorted
|
||||
|
||||
@@ -461,7 +461,7 @@ pub const Value = extern union {
|
||||
=> unreachable,
|
||||
|
||||
.ty, .lazy_align => {
|
||||
const payload = self.castTag(.ty).?;
|
||||
const payload = self.cast(Payload.Ty).?;
|
||||
const new_payload = try arena.create(Payload.Ty);
|
||||
new_payload.* = .{
|
||||
.base = payload.base,
|
||||
@@ -718,7 +718,7 @@ pub const Value = extern union {
|
||||
.lazy_align => {
|
||||
try out_stream.writeAll("@alignOf(");
|
||||
try val.castTag(.lazy_align).?.data.dump("", options, out_stream);
|
||||
try out_stream.writeAll(")");
|
||||
return try out_stream.writeAll(")");
|
||||
},
|
||||
.int_type => {
|
||||
const int_type = val.castTag(.int_type).?.data;
|
||||
@@ -2478,6 +2478,13 @@ pub const Value = extern union {
|
||||
.the_only_possible_value,
|
||||
=> return hashInt(ptr_val, hasher, target),
|
||||
|
||||
.lazy_align => {
|
||||
// Bit weird to have this here but this function is also called
|
||||
// on integers.
|
||||
const ty = ptr_val.castTag(.lazy_align).?.data;
|
||||
ty.hashWithHasher(hasher, target);
|
||||
},
|
||||
|
||||
else => unreachable,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user