| author | |
| committer | |
| log | 460e7a24451c9bf37a8c1e5e6a4554173416b149 |
| tree | 1b96c2bced6da02c69d08d6fe2299e7c1c8809b8 |
| parent | b8cd56dc94f68cda6616b4d9411d0419d2bb909f |
| parent | d5e89dd70b2b5e26e2457d276ce25125f111b29a |
| signature |
stage2: check arg count before types3 files changed, 22 insertions(+), 11 deletions(-)
build.zig+2-1| ... | @@ -613,7 +613,8 @@ fn addCxxKnownPath( | ... | @@ -613,7 +613,8 @@ fn addCxxKnownPath( |
| 613 | ctx.cxx_compiler, | 613 | ctx.cxx_compiler, |
| 614 | b.fmt("-print-file-name={s}", .{objname}), | 614 | b.fmt("-print-file-name={s}", .{objname}), |
| 615 | }); | 615 | }); |
| 616 | const path_unpadded = mem.tokenize(u8, path_padded, "\r\n").next().?; | 616 | var tokenizer = mem.tokenize(u8, path_padded, "\r\n"); |
| 617 | const path_unpadded = tokenizer.next().?; | ||
| 617 | if (mem.eql(u8, path_unpadded, objname)) { | 618 | if (mem.eql(u8, path_unpadded, objname)) { |
| 618 | if (errtxt) |msg| { | 619 | if (errtxt) |msg| { |
| 619 | std.debug.print("{s}", .{msg}); | 620 | std.debug.print("{s}", .{msg}); |
src/Sema.zig+11-8| ... | @@ -2317,8 +2317,8 @@ fn zirErrorSetDecl( | ... | @@ -2317,8 +2317,8 @@ fn zirErrorSetDecl( |
| 2317 | const extra_index_end = extra_index + (extra.data.fields_len * 2); | 2317 | const extra_index_end = extra_index + (extra.data.fields_len * 2); |
| 2318 | while (extra_index < extra_index_end) : (extra_index += 2) { // +2 to skip over doc_string | 2318 | while (extra_index < extra_index_end) : (extra_index += 2) { // +2 to skip over doc_string |
| 2319 | const str_index = sema.code.extra[extra_index]; | 2319 | const str_index = sema.code.extra[extra_index]; |
| 2320 | const name = try new_decl_arena_allocator.dupe(u8, sema.code.nullTerminatedString(str_index)); | 2320 | const kv = try sema.mod.getErrorValue(sema.code.nullTerminatedString(str_index)); |
| 2321 | const result = names.getOrPutAssumeCapacity(name); | 2321 | const result = names.getOrPutAssumeCapacity(kv.key); |
| 2322 | assert(!result.found_existing); // verified in AstGen | 2322 | assert(!result.found_existing); // verified in AstGen |
| 2323 | } | 2323 | } |
| 2324 | 2324 | ||
| ... | @@ -3661,8 +3661,12 @@ fn zirParamType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -3661,8 +3661,12 @@ fn zirParamType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 3661 | fn_ty.fnInfo(); | 3661 | fn_ty.fnInfo(); |
| 3662 | 3662 | ||
| 3663 | if (param_index >= fn_info.param_types.len) { | 3663 | if (param_index >= fn_info.param_types.len) { |
| 3664 | assert(fn_info.is_var_args); | 3664 | if (fn_info.is_var_args) { |
| 3665 | return sema.addType(Type.initTag(.var_args_param)); | 3665 | return sema.addType(Type.initTag(.var_args_param)); |
| 3666 | } | ||
| 3667 | // TODO implement begin_call/end_call Zir instructions and check | ||
| 3668 | // argument count before casting arguments to parameter types. | ||
| 3669 | return sema.fail(block, callee_src, "wrong number of arguments", .{}); | ||
| 3666 | } | 3670 | } |
| 3667 | 3671 | ||
| 3668 | if (fn_info.param_types[param_index].tag() == .generic_poison) { | 3672 | 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 | ... | @@ -13159,11 +13163,10 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I |
| 13159 | // TODO use reflection instead of magic numbers here | 13163 | // TODO use reflection instead of magic numbers here |
| 13160 | // error_set: type, | 13164 | // error_set: type, |
| 13161 | const name_val = struct_val[0]; | 13165 | const name_val = struct_val[0]; |
| 13166 | const name_str = try name_val.toAllocatedBytes(Type.initTag(.const_slice_u8), sema.arena, target); | ||
| 13162 | 13167 | ||
| 13163 | names.putAssumeCapacityNoClobber( | 13168 | const kv = try sema.mod.getErrorValue(name_str); |
| 13164 | try name_val.toAllocatedBytes(Type.initTag(.const_slice_u8), sema.arena, target), | 13169 | names.putAssumeCapacityNoClobber(kv.key, {}); |
| 13165 | {}, | ||
| 13166 | ); | ||
| 13167 | } | 13170 | } |
| 13168 | 13171 | ||
| 13169 | // names must be sorted | 13172 | // names must be sorted |
src/value.zig+9-2| ... | @@ -461,7 +461,7 @@ pub const Value = extern union { | ... | @@ -461,7 +461,7 @@ pub const Value = extern union { |
| 461 | => unreachable, | 461 | => unreachable, |
| 462 | 462 | ||
| 463 | .ty, .lazy_align => { | 463 | .ty, .lazy_align => { |
| 464 | const payload = self.castTag(.ty).?; | 464 | const payload = self.cast(Payload.Ty).?; |
| 465 | const new_payload = try arena.create(Payload.Ty); | 465 | const new_payload = try arena.create(Payload.Ty); |
| 466 | new_payload.* = .{ | 466 | new_payload.* = .{ |
| 467 | .base = payload.base, | 467 | .base = payload.base, |
| ... | @@ -718,7 +718,7 @@ pub const Value = extern union { | ... | @@ -718,7 +718,7 @@ pub const Value = extern union { |
| 718 | .lazy_align => { | 718 | .lazy_align => { |
| 719 | try out_stream.writeAll("@alignOf("); | 719 | try out_stream.writeAll("@alignOf("); |
| 720 | try val.castTag(.lazy_align).?.data.dump("", options, out_stream); | 720 | try val.castTag(.lazy_align).?.data.dump("", options, out_stream); |
| 721 | try out_stream.writeAll(")"); | 721 | return try out_stream.writeAll(")"); |
| 722 | }, | 722 | }, |
| 723 | .int_type => { | 723 | .int_type => { |
| 724 | const int_type = val.castTag(.int_type).?.data; | 724 | const int_type = val.castTag(.int_type).?.data; |
| ... | @@ -2478,6 +2478,13 @@ pub const Value = extern union { | ... | @@ -2478,6 +2478,13 @@ pub const Value = extern union { |
| 2478 | .the_only_possible_value, | 2478 | .the_only_possible_value, |
| 2479 | => return hashInt(ptr_val, hasher, target), | 2479 | => return hashInt(ptr_val, hasher, target), |
| 2480 | 2480 | ||
| 2481 | .lazy_align => { | ||
| 2482 | // Bit weird to have this here but this function is also called | ||
| 2483 | // on integers. | ||
| 2484 | const ty = ptr_val.castTag(.lazy_align).?.data; | ||
| 2485 | ty.hashWithHasher(hasher, target); | ||
| 2486 | }, | ||
| 2487 | |||
| 2481 | else => unreachable, | 2488 | else => unreachable, |
| 2482 | } | 2489 | } |
| 2483 | } | 2490 | } |