| ... | @@ -6267,7 +6267,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -6267,7 +6267,7 @@ fn zirExport(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 6267 | const decl_name = try mod.intern_pool.getOrPutString(mod.gpa, sema.code.nullTerminatedString(extra.decl_name)); | 6267 | const decl_name = try mod.intern_pool.getOrPutString(mod.gpa, sema.code.nullTerminatedString(extra.decl_name)); |
| 6268 | const decl_index = if (extra.namespace != .none) index_blk: { | 6268 | const decl_index = if (extra.namespace != .none) index_blk: { |
| 6269 | const container_ty = try sema.resolveType(block, operand_src, extra.namespace); | 6269 | const container_ty = try sema.resolveType(block, operand_src, extra.namespace); |
| 6270 | const container_namespace = container_ty.getNamespaceIndex(mod).unwrap().?; | 6270 | const container_namespace = container_ty.getNamespaceIndex(mod); |
| 6271 | | 6271 | |
| 6272 | const maybe_index = try sema.lookupInNamespace(block, operand_src, container_namespace, decl_name, false); | 6272 | const maybe_index = try sema.lookupInNamespace(block, operand_src, container_namespace, decl_name, false); |
| 6273 | break :index_blk maybe_index orelse | 6273 | break :index_blk maybe_index orelse |
| ... | @@ -6632,7 +6632,7 @@ fn lookupIdentifier(sema: *Sema, block: *Block, src: LazySrcLoc, name: InternPoo | ... | @@ -6632,7 +6632,7 @@ fn lookupIdentifier(sema: *Sema, block: *Block, src: LazySrcLoc, name: InternPoo |
| 6632 | const mod = sema.mod; | 6632 | const mod = sema.mod; |
| 6633 | var namespace = block.namespace; | 6633 | var namespace = block.namespace; |
| 6634 | while (true) { | 6634 | while (true) { |
| 6635 | if (try sema.lookupInNamespace(block, src, namespace, name, false)) |decl_index| { | 6635 | if (try sema.lookupInNamespace(block, src, namespace.toOptional(), name, false)) |decl_index| { |
| 6636 | return decl_index; | 6636 | return decl_index; |
| 6637 | } | 6637 | } |
| 6638 | namespace = mod.namespacePtr(namespace).parent.unwrap() orelse break; | 6638 | namespace = mod.namespacePtr(namespace).parent.unwrap() orelse break; |
| ... | @@ -6646,12 +6646,13 @@ fn lookupInNamespace( | ... | @@ -6646,12 +6646,13 @@ fn lookupInNamespace( |
| 6646 | sema: *Sema, | 6646 | sema: *Sema, |
| 6647 | block: *Block, | 6647 | block: *Block, |
| 6648 | src: LazySrcLoc, | 6648 | src: LazySrcLoc, |
| 6649 | namespace_index: InternPool.NamespaceIndex, | 6649 | opt_namespace_index: InternPool.OptionalNamespaceIndex, |
| 6650 | ident_name: InternPool.NullTerminatedString, | 6650 | ident_name: InternPool.NullTerminatedString, |
| 6651 | observe_usingnamespace: bool, | 6651 | observe_usingnamespace: bool, |
| 6652 | ) CompileError!?InternPool.DeclIndex { | 6652 | ) CompileError!?InternPool.DeclIndex { |
| 6653 | const mod = sema.mod; | 6653 | const mod = sema.mod; |
| 6654 | | 6654 | |
| | 6655 | const namespace_index = opt_namespace_index.unwrap() orelse return null; |
| 6655 | const namespace = mod.namespacePtr(namespace_index); | 6656 | const namespace = mod.namespacePtr(namespace_index); |
| 6656 | const namespace_decl = mod.declPtr(namespace.decl_index); | 6657 | const namespace_decl = mod.declPtr(namespace.decl_index); |
| 6657 | if (namespace_decl.analysis == .file_failure) { | 6658 | if (namespace_decl.analysis == .file_failure) { |
| ... | @@ -6696,7 +6697,7 @@ fn lookupInNamespace( | ... | @@ -6696,7 +6697,7 @@ fn lookupInNamespace( |
| 6696 | } | 6697 | } |
| 6697 | try sema.ensureDeclAnalyzed(sub_usingnamespace_decl_index); | 6698 | try sema.ensureDeclAnalyzed(sub_usingnamespace_decl_index); |
| 6698 | const ns_ty = sub_usingnamespace_decl.val.toType(); | 6699 | const ns_ty = sub_usingnamespace_decl.val.toType(); |
| 6699 | const sub_ns = ns_ty.getNamespace(mod).?; | 6700 | const sub_ns = mod.namespacePtrUnwrap(ns_ty.getNamespaceIndex(mod)) orelse continue; |
| 6700 | try checked_namespaces.put(gpa, sub_ns, src_file == sub_usingnamespace_decl.getFileScope(mod)); | 6701 | try checked_namespaces.put(gpa, sub_ns, src_file == sub_usingnamespace_decl.getFileScope(mod)); |
| 6701 | } | 6702 | } |
| 6702 | } | 6703 | } |
| ... | @@ -9917,7 +9918,7 @@ fn zirParam( | ... | @@ -9917,7 +9918,7 @@ fn zirParam( |
| 9917 | .is_comptime = comptime_syntax, | 9918 | .is_comptime = comptime_syntax, |
| 9918 | .name = param_name, | 9919 | .name = param_name, |
| 9919 | }); | 9920 | }); |
| 9920 | sema.inst_map.putAssumeCapacityNoClobber(inst, .generic_poison); | 9921 | sema.inst_map.putAssumeCapacity(inst, .generic_poison); |
| 9921 | return; | 9922 | return; |
| 9922 | }, | 9923 | }, |
| 9923 | else => |e| return e, | 9924 | else => |e| return e, |
| ... | @@ -9934,7 +9935,7 @@ fn zirParam( | ... | @@ -9934,7 +9935,7 @@ fn zirParam( |
| 9934 | .is_comptime = comptime_syntax, | 9935 | .is_comptime = comptime_syntax, |
| 9935 | .name = param_name, | 9936 | .name = param_name, |
| 9936 | }); | 9937 | }); |
| 9937 | sema.inst_map.putAssumeCapacityNoClobber(inst, .generic_poison); | 9938 | sema.inst_map.putAssumeCapacity(inst, .generic_poison); |
| 9938 | return; | 9939 | return; |
| 9939 | }, | 9940 | }, |
| 9940 | else => |e| return e, | 9941 | else => |e| return e, |
| ... | @@ -9949,7 +9950,7 @@ fn zirParam( | ... | @@ -9949,7 +9950,7 @@ fn zirParam( |
| 9949 | if (is_comptime) { | 9950 | if (is_comptime) { |
| 9950 | // If this is a comptime parameter we can add a constant generic_poison | 9951 | // If this is a comptime parameter we can add a constant generic_poison |
| 9951 | // since this is also a generic parameter. | 9952 | // since this is also a generic parameter. |
| 9952 | sema.inst_map.putAssumeCapacityNoClobber(inst, .generic_poison); | 9953 | sema.inst_map.putAssumeCapacity(inst, .generic_poison); |
| 9953 | } else { | 9954 | } else { |
| 9954 | // Otherwise we need a dummy runtime instruction. | 9955 | // Otherwise we need a dummy runtime instruction. |
| 9955 | const result_index: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); | 9956 | const result_index: Air.Inst.Index = @enumFromInt(sema.air_instructions.len); |
| ... | @@ -9957,7 +9958,7 @@ fn zirParam( | ... | @@ -9957,7 +9958,7 @@ fn zirParam( |
| 9957 | .tag = .alloc, | 9958 | .tag = .alloc, |
| 9958 | .data = .{ .ty = param_ty }, | 9959 | .data = .{ .ty = param_ty }, |
| 9959 | }); | 9960 | }); |
| 9960 | sema.inst_map.putAssumeCapacityNoClobber(inst, result_index.toRef()); | 9961 | sema.inst_map.putAssumeCapacity(inst, result_index.toRef()); |
| 9961 | } | 9962 | } |
| 9962 | } | 9963 | } |
| 9963 | | 9964 | |
| ... | @@ -13699,8 +13700,7 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -13699,8 +13700,7 @@ fn zirHasDecl(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 13699 | } }); | 13700 | } }); |
| 13700 | } | 13701 | } |
| 13701 | | 13702 | |
| 13702 | const namespace = container_type.getNamespaceIndex(mod).unwrap() orelse | 13703 | const namespace = container_type.getNamespaceIndex(mod); |
| 13703 | return .bool_false; | | |
| 13704 | if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl_index| { | 13704 | if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl_index| { |
| 13705 | const decl = mod.declPtr(decl_index); | 13705 | const decl = mod.declPtr(decl_index); |
| 13706 | if (decl.is_pub or decl.getFileScope(mod) == block.getFileScope(mod)) { | 13706 | if (decl.is_pub or decl.getFileScope(mod) == block.getFileScope(mod)) { |
| ... | @@ -17534,7 +17534,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17534,7 +17534,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17534 | const fn_info_decl_index = (try sema.namespaceLookup( | 17534 | const fn_info_decl_index = (try sema.namespaceLookup( |
| 17535 | block, | 17535 | block, |
| 17536 | src, | 17536 | src, |
| 17537 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 17537 | type_info_ty.getNamespaceIndex(mod), |
| 17538 | try ip.getOrPutString(gpa, "Fn"), | 17538 | try ip.getOrPutString(gpa, "Fn"), |
| 17539 | )).?; | 17539 | )).?; |
| 17540 | try sema.ensureDeclAnalyzed(fn_info_decl_index); | 17540 | try sema.ensureDeclAnalyzed(fn_info_decl_index); |
| ... | @@ -17544,7 +17544,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17544,7 +17544,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17544 | const param_info_decl_index = (try sema.namespaceLookup( | 17544 | const param_info_decl_index = (try sema.namespaceLookup( |
| 17545 | block, | 17545 | block, |
| 17546 | src, | 17546 | src, |
| 17547 | fn_info_ty.getNamespaceIndex(mod).unwrap().?, | 17547 | fn_info_ty.getNamespaceIndex(mod), |
| 17548 | try ip.getOrPutString(gpa, "Param"), | 17548 | try ip.getOrPutString(gpa, "Param"), |
| 17549 | )).?; | 17549 | )).?; |
| 17550 | try sema.ensureDeclAnalyzed(param_info_decl_index); | 17550 | try sema.ensureDeclAnalyzed(param_info_decl_index); |
| ... | @@ -17644,7 +17644,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17644,7 +17644,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17644 | const int_info_decl_index = (try sema.namespaceLookup( | 17644 | const int_info_decl_index = (try sema.namespaceLookup( |
| 17645 | block, | 17645 | block, |
| 17646 | src, | 17646 | src, |
| 17647 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 17647 | type_info_ty.getNamespaceIndex(mod), |
| 17648 | try ip.getOrPutString(gpa, "Int"), | 17648 | try ip.getOrPutString(gpa, "Int"), |
| 17649 | )).?; | 17649 | )).?; |
| 17650 | try sema.ensureDeclAnalyzed(int_info_decl_index); | 17650 | try sema.ensureDeclAnalyzed(int_info_decl_index); |
| ... | @@ -17672,7 +17672,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17672,7 +17672,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17672 | const float_info_decl_index = (try sema.namespaceLookup( | 17672 | const float_info_decl_index = (try sema.namespaceLookup( |
| 17673 | block, | 17673 | block, |
| 17674 | src, | 17674 | src, |
| 17675 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 17675 | type_info_ty.getNamespaceIndex(mod), |
| 17676 | try ip.getOrPutString(gpa, "Float"), | 17676 | try ip.getOrPutString(gpa, "Float"), |
| 17677 | )).?; | 17677 | )).?; |
| 17678 | try sema.ensureDeclAnalyzed(float_info_decl_index); | 17678 | try sema.ensureDeclAnalyzed(float_info_decl_index); |
| ... | @@ -17704,7 +17704,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17704,7 +17704,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17704 | const decl_index = (try sema.namespaceLookup( | 17704 | const decl_index = (try sema.namespaceLookup( |
| 17705 | block, | 17705 | block, |
| 17706 | src, | 17706 | src, |
| 17707 | (try sema.getBuiltinType("Type")).getNamespaceIndex(mod).unwrap().?, | 17707 | (try sema.getBuiltinType("Type")).getNamespaceIndex(mod), |
| 17708 | try ip.getOrPutString(gpa, "Pointer"), | 17708 | try ip.getOrPutString(gpa, "Pointer"), |
| 17709 | )).?; | 17709 | )).?; |
| 17710 | try sema.ensureDeclAnalyzed(decl_index); | 17710 | try sema.ensureDeclAnalyzed(decl_index); |
| ... | @@ -17715,7 +17715,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17715,7 +17715,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17715 | const decl_index = (try sema.namespaceLookup( | 17715 | const decl_index = (try sema.namespaceLookup( |
| 17716 | block, | 17716 | block, |
| 17717 | src, | 17717 | src, |
| 17718 | pointer_ty.getNamespaceIndex(mod).unwrap().?, | 17718 | pointer_ty.getNamespaceIndex(mod), |
| 17719 | try ip.getOrPutString(gpa, "Size"), | 17719 | try ip.getOrPutString(gpa, "Size"), |
| 17720 | )).?; | 17720 | )).?; |
| 17721 | try sema.ensureDeclAnalyzed(decl_index); | 17721 | try sema.ensureDeclAnalyzed(decl_index); |
| ... | @@ -17758,7 +17758,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17758,7 +17758,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17758 | const array_field_ty_decl_index = (try sema.namespaceLookup( | 17758 | const array_field_ty_decl_index = (try sema.namespaceLookup( |
| 17759 | block, | 17759 | block, |
| 17760 | src, | 17760 | src, |
| 17761 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 17761 | type_info_ty.getNamespaceIndex(mod), |
| 17762 | try ip.getOrPutString(gpa, "Array"), | 17762 | try ip.getOrPutString(gpa, "Array"), |
| 17763 | )).?; | 17763 | )).?; |
| 17764 | try sema.ensureDeclAnalyzed(array_field_ty_decl_index); | 17764 | try sema.ensureDeclAnalyzed(array_field_ty_decl_index); |
| ... | @@ -17789,7 +17789,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17789,7 +17789,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17789 | const vector_field_ty_decl_index = (try sema.namespaceLookup( | 17789 | const vector_field_ty_decl_index = (try sema.namespaceLookup( |
| 17790 | block, | 17790 | block, |
| 17791 | src, | 17791 | src, |
| 17792 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 17792 | type_info_ty.getNamespaceIndex(mod), |
| 17793 | try ip.getOrPutString(gpa, "Vector"), | 17793 | try ip.getOrPutString(gpa, "Vector"), |
| 17794 | )).?; | 17794 | )).?; |
| 17795 | try sema.ensureDeclAnalyzed(vector_field_ty_decl_index); | 17795 | try sema.ensureDeclAnalyzed(vector_field_ty_decl_index); |
| ... | @@ -17818,7 +17818,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17818,7 +17818,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17818 | const optional_field_ty_decl_index = (try sema.namespaceLookup( | 17818 | const optional_field_ty_decl_index = (try sema.namespaceLookup( |
| 17819 | block, | 17819 | block, |
| 17820 | src, | 17820 | src, |
| 17821 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 17821 | type_info_ty.getNamespaceIndex(mod), |
| 17822 | try ip.getOrPutString(gpa, "Optional"), | 17822 | try ip.getOrPutString(gpa, "Optional"), |
| 17823 | )).?; | 17823 | )).?; |
| 17824 | try sema.ensureDeclAnalyzed(optional_field_ty_decl_index); | 17824 | try sema.ensureDeclAnalyzed(optional_field_ty_decl_index); |
| ... | @@ -17845,7 +17845,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17845,7 +17845,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17845 | const set_field_ty_decl_index = (try sema.namespaceLookup( | 17845 | const set_field_ty_decl_index = (try sema.namespaceLookup( |
| 17846 | block, | 17846 | block, |
| 17847 | src, | 17847 | src, |
| 17848 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 17848 | type_info_ty.getNamespaceIndex(mod), |
| 17849 | try ip.getOrPutString(gpa, "Error"), | 17849 | try ip.getOrPutString(gpa, "Error"), |
| 17850 | )).?; | 17850 | )).?; |
| 17851 | try sema.ensureDeclAnalyzed(set_field_ty_decl_index); | 17851 | try sema.ensureDeclAnalyzed(set_field_ty_decl_index); |
| ... | @@ -17950,7 +17950,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17950,7 +17950,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17950 | const error_union_field_ty_decl_index = (try sema.namespaceLookup( | 17950 | const error_union_field_ty_decl_index = (try sema.namespaceLookup( |
| 17951 | block, | 17951 | block, |
| 17952 | src, | 17952 | src, |
| 17953 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 17953 | type_info_ty.getNamespaceIndex(mod), |
| 17954 | try ip.getOrPutString(gpa, "ErrorUnion"), | 17954 | try ip.getOrPutString(gpa, "ErrorUnion"), |
| 17955 | )).?; | 17955 | )).?; |
| 17956 | try sema.ensureDeclAnalyzed(error_union_field_ty_decl_index); | 17956 | try sema.ensureDeclAnalyzed(error_union_field_ty_decl_index); |
| ... | @@ -17980,7 +17980,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17980,7 +17980,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17980 | const enum_field_ty_decl_index = (try sema.namespaceLookup( | 17980 | const enum_field_ty_decl_index = (try sema.namespaceLookup( |
| 17981 | block, | 17981 | block, |
| 17982 | src, | 17982 | src, |
| 17983 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 17983 | type_info_ty.getNamespaceIndex(mod), |
| 17984 | try ip.getOrPutString(gpa, "EnumField"), | 17984 | try ip.getOrPutString(gpa, "EnumField"), |
| 17985 | )).?; | 17985 | )).?; |
| 17986 | try sema.ensureDeclAnalyzed(enum_field_ty_decl_index); | 17986 | try sema.ensureDeclAnalyzed(enum_field_ty_decl_index); |
| ... | @@ -18071,7 +18071,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18071,7 +18071,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18071 | const type_enum_ty_decl_index = (try sema.namespaceLookup( | 18071 | const type_enum_ty_decl_index = (try sema.namespaceLookup( |
| 18072 | block, | 18072 | block, |
| 18073 | src, | 18073 | src, |
| 18074 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 18074 | type_info_ty.getNamespaceIndex(mod), |
| 18075 | try ip.getOrPutString(gpa, "Enum"), | 18075 | try ip.getOrPutString(gpa, "Enum"), |
| 18076 | )).?; | 18076 | )).?; |
| 18077 | try sema.ensureDeclAnalyzed(type_enum_ty_decl_index); | 18077 | try sema.ensureDeclAnalyzed(type_enum_ty_decl_index); |
| ... | @@ -18103,7 +18103,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18103,7 +18103,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18103 | const type_union_ty_decl_index = (try sema.namespaceLookup( | 18103 | const type_union_ty_decl_index = (try sema.namespaceLookup( |
| 18104 | block, | 18104 | block, |
| 18105 | src, | 18105 | src, |
| 18106 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 18106 | type_info_ty.getNamespaceIndex(mod), |
| 18107 | try ip.getOrPutString(gpa, "Union"), | 18107 | try ip.getOrPutString(gpa, "Union"), |
| 18108 | )).?; | 18108 | )).?; |
| 18109 | try sema.ensureDeclAnalyzed(type_union_ty_decl_index); | 18109 | try sema.ensureDeclAnalyzed(type_union_ty_decl_index); |
| ... | @@ -18115,7 +18115,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18115,7 +18115,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18115 | const union_field_ty_decl_index = (try sema.namespaceLookup( | 18115 | const union_field_ty_decl_index = (try sema.namespaceLookup( |
| 18116 | block, | 18116 | block, |
| 18117 | src, | 18117 | src, |
| 18118 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 18118 | type_info_ty.getNamespaceIndex(mod), |
| 18119 | try ip.getOrPutString(gpa, "UnionField"), | 18119 | try ip.getOrPutString(gpa, "UnionField"), |
| 18120 | )).?; | 18120 | )).?; |
| 18121 | try sema.ensureDeclAnalyzed(union_field_ty_decl_index); | 18121 | try sema.ensureDeclAnalyzed(union_field_ty_decl_index); |
| ... | @@ -18217,7 +18217,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18217,7 +18217,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18217 | const decl_index = (try sema.namespaceLookup( | 18217 | const decl_index = (try sema.namespaceLookup( |
| 18218 | block, | 18218 | block, |
| 18219 | src, | 18219 | src, |
| 18220 | (try sema.getBuiltinType("Type")).getNamespaceIndex(mod).unwrap().?, | 18220 | (try sema.getBuiltinType("Type")).getNamespaceIndex(mod), |
| 18221 | try ip.getOrPutString(gpa, "ContainerLayout"), | 18221 | try ip.getOrPutString(gpa, "ContainerLayout"), |
| 18222 | )).?; | 18222 | )).?; |
| 18223 | try sema.ensureDeclAnalyzed(decl_index); | 18223 | try sema.ensureDeclAnalyzed(decl_index); |
| ... | @@ -18250,7 +18250,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18250,7 +18250,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18250 | const type_struct_ty_decl_index = (try sema.namespaceLookup( | 18250 | const type_struct_ty_decl_index = (try sema.namespaceLookup( |
| 18251 | block, | 18251 | block, |
| 18252 | src, | 18252 | src, |
| 18253 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 18253 | type_info_ty.getNamespaceIndex(mod), |
| 18254 | try ip.getOrPutString(gpa, "Struct"), | 18254 | try ip.getOrPutString(gpa, "Struct"), |
| 18255 | )).?; | 18255 | )).?; |
| 18256 | try sema.ensureDeclAnalyzed(type_struct_ty_decl_index); | 18256 | try sema.ensureDeclAnalyzed(type_struct_ty_decl_index); |
| ... | @@ -18262,7 +18262,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18262,7 +18262,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18262 | const struct_field_ty_decl_index = (try sema.namespaceLookup( | 18262 | const struct_field_ty_decl_index = (try sema.namespaceLookup( |
| 18263 | block, | 18263 | block, |
| 18264 | src, | 18264 | src, |
| 18265 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 18265 | type_info_ty.getNamespaceIndex(mod), |
| 18266 | try ip.getOrPutString(gpa, "StructField"), | 18266 | try ip.getOrPutString(gpa, "StructField"), |
| 18267 | )).?; | 18267 | )).?; |
| 18268 | try sema.ensureDeclAnalyzed(struct_field_ty_decl_index); | 18268 | try sema.ensureDeclAnalyzed(struct_field_ty_decl_index); |
| ... | @@ -18447,7 +18447,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18447,7 +18447,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18447 | const decl_index = (try sema.namespaceLookup( | 18447 | const decl_index = (try sema.namespaceLookup( |
| 18448 | block, | 18448 | block, |
| 18449 | src, | 18449 | src, |
| 18450 | (try sema.getBuiltinType("Type")).getNamespaceIndex(mod).unwrap().?, | 18450 | (try sema.getBuiltinType("Type")).getNamespaceIndex(mod), |
| 18451 | try ip.getOrPutString(gpa, "ContainerLayout"), | 18451 | try ip.getOrPutString(gpa, "ContainerLayout"), |
| 18452 | )).?; | 18452 | )).?; |
| 18453 | try sema.ensureDeclAnalyzed(decl_index); | 18453 | try sema.ensureDeclAnalyzed(decl_index); |
| ... | @@ -18483,7 +18483,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -18483,7 +18483,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18483 | const type_opaque_ty_decl_index = (try sema.namespaceLookup( | 18483 | const type_opaque_ty_decl_index = (try sema.namespaceLookup( |
| 18484 | block, | 18484 | block, |
| 18485 | src, | 18485 | src, |
| 18486 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 18486 | type_info_ty.getNamespaceIndex(mod), |
| 18487 | try ip.getOrPutString(gpa, "Opaque"), | 18487 | try ip.getOrPutString(gpa, "Opaque"), |
| 18488 | )).?; | 18488 | )).?; |
| 18489 | try sema.ensureDeclAnalyzed(type_opaque_ty_decl_index); | 18489 | try sema.ensureDeclAnalyzed(type_opaque_ty_decl_index); |
| ... | @@ -18526,7 +18526,7 @@ fn typeInfoDecls( | ... | @@ -18526,7 +18526,7 @@ fn typeInfoDecls( |
| 18526 | const declaration_ty_decl_index = (try sema.namespaceLookup( | 18526 | const declaration_ty_decl_index = (try sema.namespaceLookup( |
| 18527 | block, | 18527 | block, |
| 18528 | src, | 18528 | src, |
| 18529 | type_info_ty.getNamespaceIndex(mod).unwrap().?, | 18529 | type_info_ty.getNamespaceIndex(mod), |
| 18530 | try mod.intern_pool.getOrPutString(gpa, "Declaration"), | 18530 | try mod.intern_pool.getOrPutString(gpa, "Declaration"), |
| 18531 | )).?; | 18531 | )).?; |
| 18532 | try sema.ensureDeclAnalyzed(declaration_ty_decl_index); | 18532 | try sema.ensureDeclAnalyzed(declaration_ty_decl_index); |
| ... | @@ -18541,10 +18541,7 @@ fn typeInfoDecls( | ... | @@ -18541,10 +18541,7 @@ fn typeInfoDecls( |
| 18541 | var seen_namespaces = std.AutoHashMap(*Namespace, void).init(gpa); | 18541 | var seen_namespaces = std.AutoHashMap(*Namespace, void).init(gpa); |
| 18542 | defer seen_namespaces.deinit(); | 18542 | defer seen_namespaces.deinit(); |
| 18543 | | 18543 | |
| 18544 | if (opt_namespace.unwrap()) |namespace_index| { | 18544 | try sema.typeInfoNamespaceDecls(block, opt_namespace, declaration_ty, &decl_vals, &seen_namespaces); |
| 18545 | const namespace = mod.namespacePtr(namespace_index); | | |
| 18546 | try sema.typeInfoNamespaceDecls(block, namespace, declaration_ty, &decl_vals, &seen_namespaces); | | |
| 18547 | } | | |
| 18548 | | 18545 | |
| 18549 | const array_decl_ty = try mod.arrayType(.{ | 18546 | const array_decl_ty = try mod.arrayType(.{ |
| 18550 | .len = decl_vals.items.len, | 18547 | .len = decl_vals.items.len, |
| ... | @@ -18577,23 +18574,27 @@ fn typeInfoDecls( | ... | @@ -18577,23 +18574,27 @@ fn typeInfoDecls( |
| 18577 | fn typeInfoNamespaceDecls( | 18574 | fn typeInfoNamespaceDecls( |
| 18578 | sema: *Sema, | 18575 | sema: *Sema, |
| 18579 | block: *Block, | 18576 | block: *Block, |
| 18580 | namespace: *Namespace, | 18577 | opt_namespace_index: InternPool.OptionalNamespaceIndex, |
| 18581 | declaration_ty: Type, | 18578 | declaration_ty: Type, |
| 18582 | decl_vals: *std.ArrayList(InternPool.Index), | 18579 | decl_vals: *std.ArrayList(InternPool.Index), |
| 18583 | seen_namespaces: *std.AutoHashMap(*Namespace, void), | 18580 | seen_namespaces: *std.AutoHashMap(*Namespace, void), |
| 18584 | ) !void { | 18581 | ) !void { |
| 18585 | const mod = sema.mod; | 18582 | const mod = sema.mod; |
| 18586 | const ip = &mod.intern_pool; | 18583 | const ip = &mod.intern_pool; |
| | 18584 | |
| | 18585 | const namespace_index = opt_namespace_index.unwrap() orelse return; |
| | 18586 | const namespace = mod.namespacePtr(namespace_index); |
| | 18587 | |
| 18587 | const gop = try seen_namespaces.getOrPut(namespace); | 18588 | const gop = try seen_namespaces.getOrPut(namespace); |
| 18588 | if (gop.found_existing) return; | 18589 | if (gop.found_existing) return; |
| | 18590 | |
| 18589 | const decls = namespace.decls.keys(); | 18591 | const decls = namespace.decls.keys(); |
| 18590 | for (decls) |decl_index| { | 18592 | for (decls) |decl_index| { |
| 18591 | const decl = mod.declPtr(decl_index); | 18593 | const decl = mod.declPtr(decl_index); |
| 18592 | if (decl.kind == .@"usingnamespace") { | 18594 | if (decl.kind == .@"usingnamespace") { |
| 18593 | if (decl.analysis == .in_progress) continue; | 18595 | if (decl.analysis == .in_progress) continue; |
| 18594 | try mod.ensureDeclAnalyzed(decl_index); | 18596 | try mod.ensureDeclAnalyzed(decl_index); |
| 18595 | const new_ns = decl.val.toType().getNamespace(mod).?; | 18597 | try sema.typeInfoNamespaceDecls(block, decl.val.toType().getNamespaceIndex(mod), declaration_ty, decl_vals, seen_namespaces); |
| 18596 | try sema.typeInfoNamespaceDecls(block, new_ns, declaration_ty, decl_vals, seen_namespaces); | | |
| 18597 | continue; | 18598 | continue; |
| 18598 | } | 18599 | } |
| 18599 | if (decl.kind != .named or !decl.is_pub) continue; | 18600 | if (decl.kind != .named or !decl.is_pub) continue; |
| ... | @@ -19744,7 +19745,8 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE | ... | @@ -19744,7 +19745,8 @@ fn zirStructInitEmpty(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE |
| 19744 | | 19745 | |
| 19745 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; | 19746 | const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].un_node; |
| 19746 | const src = inst_data.src(); | 19747 | const src = inst_data.src(); |
| 19747 | const obj_ty = try sema.resolveType(block, src, inst_data.operand); | 19748 | const ty_src: LazySrcLoc = .{ .node_offset_init_ty = inst_data.src_node }; |
| | 19749 | const obj_ty = try sema.resolveType(block, ty_src, inst_data.operand); |
| 19748 | const mod = sema.mod; | 19750 | const mod = sema.mod; |
| 19749 | | 19751 | |
| 19750 | switch (obj_ty.zigTypeTag(mod)) { | 19752 | switch (obj_ty.zigTypeTag(mod)) { |
| ... | @@ -26558,7 +26560,7 @@ fn preparePanicId(sema: *Sema, block: *Block, panic_id: Module.PanicId) !InternP | ... | @@ -26558,7 +26560,7 @@ fn preparePanicId(sema: *Sema, block: *Block, panic_id: Module.PanicId) !InternP |
| 26558 | const msg_decl_index = (sema.namespaceLookup( | 26560 | const msg_decl_index = (sema.namespaceLookup( |
| 26559 | block, | 26561 | block, |
| 26560 | .unneeded, | 26562 | .unneeded, |
| 26561 | panic_messages_ty.getNamespaceIndex(mod).unwrap().?, | 26563 | panic_messages_ty.getNamespaceIndex(mod), |
| 26562 | try mod.intern_pool.getOrPutString(gpa, @tagName(panic_id)), | 26564 | try mod.intern_pool.getOrPutString(gpa, @tagName(panic_id)), |
| 26563 | ) catch |err| switch (err) { | 26565 | ) catch |err| switch (err) { |
| 26564 | error.AnalysisFail, error.NeededSourceLocation => @panic("std.builtin.panic_messages is corrupt"), | 26566 | error.AnalysisFail, error.NeededSourceLocation => @panic("std.builtin.panic_messages is corrupt"), |
| ... | @@ -26977,10 +26979,8 @@ fn fieldVal( | ... | @@ -26977,10 +26979,8 @@ fn fieldVal( |
| 26977 | } }))); | 26979 | } }))); |
| 26978 | }, | 26980 | }, |
| 26979 | .Union => { | 26981 | .Union => { |
| 26980 | if (child_type.getNamespaceIndex(mod).unwrap()) |namespace| { | 26982 | if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(mod), field_name)) |inst| { |
| 26981 | if (try sema.namespaceLookupVal(block, src, namespace, field_name)) |inst| { | 26983 | return inst; |
| 26982 | return inst; | | |
| 26983 | } | | |
| 26984 | } | 26984 | } |
| 26985 | try sema.resolveTypeFields(child_type); | 26985 | try sema.resolveTypeFields(child_type); |
| 26986 | if (child_type.unionTagType(mod)) |enum_ty| { | 26986 | if (child_type.unionTagType(mod)) |enum_ty| { |
| ... | @@ -26992,10 +26992,8 @@ fn fieldVal( | ... | @@ -26992,10 +26992,8 @@ fn fieldVal( |
| 26992 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); | 26992 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| 26993 | }, | 26993 | }, |
| 26994 | .Enum => { | 26994 | .Enum => { |
| 26995 | if (child_type.getNamespaceIndex(mod).unwrap()) |namespace| { | 26995 | if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(mod), field_name)) |inst| { |
| 26996 | if (try sema.namespaceLookupVal(block, src, namespace, field_name)) |inst| { | 26996 | return inst; |
| 26997 | return inst; | | |
| 26998 | } | | |
| 26999 | } | 26997 | } |
| 27000 | const field_index_usize = child_type.enumFieldIndex(field_name, mod) orelse | 26998 | const field_index_usize = child_type.enumFieldIndex(field_name, mod) orelse |
| 27001 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); | 26999 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| ... | @@ -27004,10 +27002,8 @@ fn fieldVal( | ... | @@ -27004,10 +27002,8 @@ fn fieldVal( |
| 27004 | return Air.internedToRef(enum_val.toIntern()); | 27002 | return Air.internedToRef(enum_val.toIntern()); |
| 27005 | }, | 27003 | }, |
| 27006 | .Struct, .Opaque => { | 27004 | .Struct, .Opaque => { |
| 27007 | if (child_type.getNamespaceIndex(mod).unwrap()) |namespace| { | 27005 | if (try sema.namespaceLookupVal(block, src, child_type.getNamespaceIndex(mod), field_name)) |inst| { |
| 27008 | if (try sema.namespaceLookupVal(block, src, namespace, field_name)) |inst| { | 27006 | return inst; |
| 27009 | return inst; | | |
| 27010 | } | | |
| 27011 | } | 27007 | } |
| 27012 | return sema.failWithBadMemberAccess(block, child_type, src, field_name); | 27008 | return sema.failWithBadMemberAccess(block, child_type, src, field_name); |
| 27013 | }, | 27009 | }, |
| ... | @@ -27203,10 +27199,8 @@ fn fieldPtr( | ... | @@ -27203,10 +27199,8 @@ fn fieldPtr( |
| 27203 | } })); | 27199 | } })); |
| 27204 | }, | 27200 | }, |
| 27205 | .Union => { | 27201 | .Union => { |
| 27206 | if (child_type.getNamespaceIndex(mod).unwrap()) |namespace| { | 27202 | if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(mod), field_name)) |inst| { |
| 27207 | if (try sema.namespaceLookupRef(block, src, namespace, field_name)) |inst| { | 27203 | return inst; |
| 27208 | return inst; | | |
| 27209 | } | | |
| 27210 | } | 27204 | } |
| 27211 | try sema.resolveTypeFields(child_type); | 27205 | try sema.resolveTypeFields(child_type); |
| 27212 | if (child_type.unionTagType(mod)) |enum_ty| { | 27206 | if (child_type.unionTagType(mod)) |enum_ty| { |
| ... | @@ -27219,10 +27213,8 @@ fn fieldPtr( | ... | @@ -27219,10 +27213,8 @@ fn fieldPtr( |
| 27219 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); | 27213 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| 27220 | }, | 27214 | }, |
| 27221 | .Enum => { | 27215 | .Enum => { |
| 27222 | if (child_type.getNamespaceIndex(mod).unwrap()) |namespace| { | 27216 | if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(mod), field_name)) |inst| { |
| 27223 | if (try sema.namespaceLookupRef(block, src, namespace, field_name)) |inst| { | 27217 | return inst; |
| 27224 | return inst; | | |
| 27225 | } | | |
| 27226 | } | 27218 | } |
| 27227 | const field_index = child_type.enumFieldIndex(field_name, mod) orelse { | 27219 | const field_index = child_type.enumFieldIndex(field_name, mod) orelse { |
| 27228 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); | 27220 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| ... | @@ -27232,10 +27224,8 @@ fn fieldPtr( | ... | @@ -27232,10 +27224,8 @@ fn fieldPtr( |
| 27232 | return anonDeclRef(sema, idx_val.toIntern()); | 27224 | return anonDeclRef(sema, idx_val.toIntern()); |
| 27233 | }, | 27225 | }, |
| 27234 | .Struct, .Opaque => { | 27226 | .Struct, .Opaque => { |
| 27235 | if (child_type.getNamespaceIndex(mod).unwrap()) |namespace| { | 27227 | if (try sema.namespaceLookupRef(block, src, child_type.getNamespaceIndex(mod), field_name)) |inst| { |
| 27236 | if (try sema.namespaceLookupRef(block, src, namespace, field_name)) |inst| { | 27228 | return inst; |
| 27237 | return inst; | | |
| 27238 | } | | |
| 27239 | } | 27229 | } |
| 27240 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); | 27230 | return sema.failWithBadMemberAccess(block, child_type, field_name_src, field_name); |
| 27241 | }, | 27231 | }, |
| ... | @@ -27348,73 +27338,68 @@ fn fieldCallBind( | ... | @@ -27348,73 +27338,68 @@ fn fieldCallBind( |
| 27348 | } | 27338 | } |
| 27349 | | 27339 | |
| 27350 | // If we get here, we need to look for a decl in the struct type instead. | 27340 | // If we get here, we need to look for a decl in the struct type instead. |
| 27351 | const found_decl = switch (concrete_ty.zigTypeTag(mod)) { | 27341 | const found_decl = found_decl: { |
| 27352 | .Struct, .Opaque, .Union, .Enum => found_decl: { | 27342 | const namespace = concrete_ty.getNamespace(mod) orelse |
| 27353 | if (concrete_ty.getNamespaceIndex(mod).unwrap()) |namespace| { | 27343 | break :found_decl null; |
| 27354 | if (try sema.namespaceLookup(block, src, namespace, field_name)) |decl_idx| { | 27344 | const decl_idx = (try sema.namespaceLookup(block, src, namespace, field_name)) orelse |
| 27355 | try sema.addReferencedBy(block, src, decl_idx); | 27345 | break :found_decl null; |
| 27356 | const decl_val = try sema.analyzeDeclVal(block, src, decl_idx); | 27346 | |
| 27357 | const decl_type = sema.typeOf(decl_val); | 27347 | try sema.addReferencedBy(block, src, decl_idx); |
| 27358 | if (mod.typeToFunc(decl_type)) |func_type| f: { | 27348 | const decl_val = try sema.analyzeDeclVal(block, src, decl_idx); |
| 27359 | if (func_type.param_types.len == 0) break :f; | 27349 | const decl_type = sema.typeOf(decl_val); |
| 27360 | | 27350 | if (mod.typeToFunc(decl_type)) |func_type| f: { |
| 27361 | const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]); | 27351 | if (func_type.param_types.len == 0) break :f; |
| 27362 | // zig fmt: off | 27352 | |
| 27363 | if (first_param_type.isGenericPoison() or ( | 27353 | const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]); |
| 27364 | first_param_type.zigTypeTag(mod) == .Pointer and | 27354 | if (first_param_type.isGenericPoison() or |
| 27365 | (first_param_type.ptrSize(mod) == .One or | 27355 | (first_param_type.zigTypeTag(mod) == .Pointer and |
| 27366 | first_param_type.ptrSize(mod) == .C) and | 27356 | (first_param_type.ptrSize(mod) == .One or |
| 27367 | first_param_type.childType(mod).eql(concrete_ty, mod))) | 27357 | first_param_type.ptrSize(mod) == .C) and |
| 27368 | { | 27358 | first_param_type.childType(mod).eql(concrete_ty, mod))) |
| 27369 | // zig fmt: on | 27359 | { |
| 27370 | // Note that if the param type is generic poison, we know that it must | 27360 | // Note that if the param type is generic poison, we know that it must |
| 27371 | // specifically be `anytype` since it's the first parameter, meaning we | 27361 | // specifically be `anytype` since it's the first parameter, meaning we |
| 27372 | // can safely assume it can be a pointer. | 27362 | // can safely assume it can be a pointer. |
| 27373 | // TODO: bound fn calls on rvalues should probably | 27363 | // TODO: bound fn calls on rvalues should probably |
| 27374 | // generate a by-value argument somehow. | 27364 | // generate a by-value argument somehow. |
| 27375 | return .{ .method = .{ | 27365 | return .{ .method = .{ |
| 27376 | .func_inst = decl_val, | 27366 | .func_inst = decl_val, |
| 27377 | .arg0_inst = object_ptr, | 27367 | .arg0_inst = object_ptr, |
| 27378 | } }; | 27368 | } }; |
| 27379 | } else if (first_param_type.eql(concrete_ty, mod)) { | 27369 | } else if (first_param_type.eql(concrete_ty, mod)) { |
| 27380 | const deref = try sema.analyzeLoad(block, src, object_ptr, src); | 27370 | const deref = try sema.analyzeLoad(block, src, object_ptr, src); |
| 27381 | return .{ .method = .{ | 27371 | return .{ .method = .{ |
| 27382 | .func_inst = decl_val, | 27372 | .func_inst = decl_val, |
| 27383 | .arg0_inst = deref, | 27373 | .arg0_inst = deref, |
| 27384 | } }; | 27374 | } }; |
| 27385 | } else if (first_param_type.zigTypeTag(mod) == .Optional) { | 27375 | } else if (first_param_type.zigTypeTag(mod) == .Optional) { |
| 27386 | const child = first_param_type.optionalChild(mod); | 27376 | const child = first_param_type.optionalChild(mod); |
| 27387 | if (child.eql(concrete_ty, mod)) { | 27377 | if (child.eql(concrete_ty, mod)) { |
| 27388 | const deref = try sema.analyzeLoad(block, src, object_ptr, src); | 27378 | const deref = try sema.analyzeLoad(block, src, object_ptr, src); |
| 27389 | return .{ .method = .{ | 27379 | return .{ .method = .{ |
| 27390 | .func_inst = decl_val, | 27380 | .func_inst = decl_val, |
| 27391 | .arg0_inst = deref, | 27381 | .arg0_inst = deref, |
| 27392 | } }; | 27382 | } }; |
| 27393 | } else if (child.zigTypeTag(mod) == .Pointer and | 27383 | } else if (child.zigTypeTag(mod) == .Pointer and |
| 27394 | child.ptrSize(mod) == .One and | 27384 | child.ptrSize(mod) == .One and |
| 27395 | child.childType(mod).eql(concrete_ty, mod)) | 27385 | child.childType(mod).eql(concrete_ty, mod)) |
| 27396 | { | 27386 | { |
| 27397 | return .{ .method = .{ | 27387 | return .{ .method = .{ |
| 27398 | .func_inst = decl_val, | 27388 | .func_inst = decl_val, |
| 27399 | .arg0_inst = object_ptr, | 27389 | .arg0_inst = object_ptr, |
| 27400 | } }; | 27390 | } }; |
| 27401 | } | | |
| 27402 | } else if (first_param_type.zigTypeTag(mod) == .ErrorUnion and | | |
| 27403 | first_param_type.errorUnionPayload(mod).eql(concrete_ty, mod)) | | |
| 27404 | { | | |
| 27405 | const deref = try sema.analyzeLoad(block, src, object_ptr, src); | | |
| 27406 | return .{ .method = .{ | | |
| 27407 | .func_inst = decl_val, | | |
| 27408 | .arg0_inst = deref, | | |
| 27409 | } }; | | |
| 27410 | } | | |
| 27411 | } | | |
| 27412 | break :found_decl decl_idx; | | |
| 27413 | } | 27391 | } |
| | 27392 | } else if (first_param_type.zigTypeTag(mod) == .ErrorUnion and |
| | 27393 | first_param_type.errorUnionPayload(mod).eql(concrete_ty, mod)) |
| | 27394 | { |
| | 27395 | const deref = try sema.analyzeLoad(block, src, object_ptr, src); |
| | 27396 | return .{ .method = .{ |
| | 27397 | .func_inst = decl_val, |
| | 27398 | .arg0_inst = deref, |
| | 27399 | } }; |
| 27414 | } | 27400 | } |
| 27415 | break :found_decl null; | 27401 | } |
| 27416 | }, | 27402 | break :found_decl decl_idx; |
| 27417 | else => null, | | |
| 27418 | }; | 27403 | }; |
| 27419 | | 27404 | |
| 27420 | const msg = msg: { | 27405 | const msg = msg: { |
| ... | @@ -27480,12 +27465,12 @@ fn namespaceLookup( | ... | @@ -27480,12 +27465,12 @@ fn namespaceLookup( |
| 27480 | sema: *Sema, | 27465 | sema: *Sema, |
| 27481 | block: *Block, | 27466 | block: *Block, |
| 27482 | src: LazySrcLoc, | 27467 | src: LazySrcLoc, |
| 27483 | namespace: InternPool.NamespaceIndex, | 27468 | opt_namespace: InternPool.OptionalNamespaceIndex, |
| 27484 | decl_name: InternPool.NullTerminatedString, | 27469 | decl_name: InternPool.NullTerminatedString, |
| 27485 | ) CompileError!?InternPool.DeclIndex { | 27470 | ) CompileError!?InternPool.DeclIndex { |
| 27486 | const mod = sema.mod; | 27471 | const mod = sema.mod; |
| 27487 | const gpa = sema.gpa; | 27472 | const gpa = sema.gpa; |
| 27488 | if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl_index| { | 27473 | if (try sema.lookupInNamespace(block, src, opt_namespace, decl_name, true)) |decl_index| { |
| 27489 | const decl = mod.declPtr(decl_index); | 27474 | const decl = mod.declPtr(decl_index); |
| 27490 | if (!decl.is_pub and decl.getFileScope(mod) != block.getFileScope(mod)) { | 27475 | if (!decl.is_pub and decl.getFileScope(mod) != block.getFileScope(mod)) { |
| 27491 | const msg = msg: { | 27476 | const msg = msg: { |
| ... | @@ -27507,10 +27492,10 @@ fn namespaceLookupRef( | ... | @@ -27507,10 +27492,10 @@ fn namespaceLookupRef( |
| 27507 | sema: *Sema, | 27492 | sema: *Sema, |
| 27508 | block: *Block, | 27493 | block: *Block, |
| 27509 | src: LazySrcLoc, | 27494 | src: LazySrcLoc, |
| 27510 | namespace: InternPool.NamespaceIndex, | 27495 | opt_namespace: InternPool.OptionalNamespaceIndex, |
| 27511 | decl_name: InternPool.NullTerminatedString, | 27496 | decl_name: InternPool.NullTerminatedString, |
| 27512 | ) CompileError!?Air.Inst.Ref { | 27497 | ) CompileError!?Air.Inst.Ref { |
| 27513 | const decl = (try sema.namespaceLookup(block, src, namespace, decl_name)) orelse return null; | 27498 | const decl = (try sema.namespaceLookup(block, src, opt_namespace, decl_name)) orelse return null; |
| 27514 | try sema.addReferencedBy(block, src, decl); | 27499 | try sema.addReferencedBy(block, src, decl); |
| 27515 | return try sema.analyzeDeclRef(decl); | 27500 | return try sema.analyzeDeclRef(decl); |
| 27516 | } | 27501 | } |
| ... | @@ -27519,10 +27504,10 @@ fn namespaceLookupVal( | ... | @@ -27519,10 +27504,10 @@ fn namespaceLookupVal( |
| 27519 | sema: *Sema, | 27504 | sema: *Sema, |
| 27520 | block: *Block, | 27505 | block: *Block, |
| 27521 | src: LazySrcLoc, | 27506 | src: LazySrcLoc, |
| 27522 | namespace: InternPool.NamespaceIndex, | 27507 | opt_namespace: InternPool.OptionalNamespaceIndex, |
| 27523 | decl_name: InternPool.NullTerminatedString, | 27508 | decl_name: InternPool.NullTerminatedString, |
| 27524 | ) CompileError!?Air.Inst.Ref { | 27509 | ) CompileError!?Air.Inst.Ref { |
| 27525 | const decl = (try sema.namespaceLookup(block, src, namespace, decl_name)) orelse return null; | 27510 | const decl = (try sema.namespaceLookup(block, src, opt_namespace, decl_name)) orelse return null; |
| 27526 | return try sema.analyzeDeclVal(block, src, decl); | 27511 | return try sema.analyzeDeclVal(block, src, decl); |
| 27527 | } | 27512 | } |
| 27528 | | 27513 | |
| ... | @@ -37580,7 +37565,7 @@ fn getBuiltinDecl(sema: *Sema, block: *Block, name: []const u8) CompileError!Int | ... | @@ -37580,7 +37565,7 @@ fn getBuiltinDecl(sema: *Sema, block: *Block, name: []const u8) CompileError!Int |
| 37580 | const opt_builtin_inst = (try sema.namespaceLookupRef( | 37565 | const opt_builtin_inst = (try sema.namespaceLookupRef( |
| 37581 | block, | 37566 | block, |
| 37582 | src, | 37567 | src, |
| 37583 | mod.declPtr(std_file.root_decl.unwrap().?).src_namespace, | 37568 | mod.declPtr(std_file.root_decl.unwrap().?).src_namespace.toOptional(), |
| 37584 | try ip.getOrPutString(gpa, "builtin"), | 37569 | try ip.getOrPutString(gpa, "builtin"), |
| 37585 | )) orelse @panic("lib/std.zig is corrupt and missing 'builtin'"); | 37570 | )) orelse @panic("lib/std.zig is corrupt and missing 'builtin'"); |
| 37586 | const builtin_inst = try sema.analyzeLoad(block, src, opt_builtin_inst, src); | 37571 | const builtin_inst = try sema.analyzeLoad(block, src, opt_builtin_inst, src); |
| ... | @@ -37591,7 +37576,7 @@ fn getBuiltinDecl(sema: *Sema, block: *Block, name: []const u8) CompileError!Int | ... | @@ -37591,7 +37576,7 @@ fn getBuiltinDecl(sema: *Sema, block: *Block, name: []const u8) CompileError!Int |
| 37591 | const decl_index = (try sema.namespaceLookup( | 37576 | const decl_index = (try sema.namespaceLookup( |
| 37592 | block, | 37577 | block, |
| 37593 | src, | 37578 | src, |
| 37594 | builtin_ty.getNamespaceIndex(mod).unwrap().?, | 37579 | builtin_ty.getNamespaceIndex(mod), |
| 37595 | try ip.getOrPutString(gpa, name), | 37580 | try ip.getOrPutString(gpa, name), |
| 37596 | )) orelse std.debug.panic("lib/std/builtin.zig is corrupt and missing '{s}'", .{name}); | 37581 | )) orelse std.debug.panic("lib/std/builtin.zig is corrupt and missing '{s}'", .{name}); |
| 37597 | return decl_index; | 37582 | return decl_index; |