| ... | ... | @@ -5668,7 +5668,15 @@ fn zirExportValue(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 5668 | 5668 | }; |
| 5669 | 5669 | const decl_index = switch (operand.val.tag()) { |
| 5670 | 5670 | .function => operand.val.castTag(.function).?.data.owner_decl, |
| 5671 | | else => return sema.fail(block, operand_src, "TODO implement exporting arbitrary Value objects", .{}), // TODO put this Value into an anonymous Decl and then export it. |
| 5671 | else => blk: { |
| 5672 | var anon_decl = try block.startAnonDecl(); |
| 5673 | defer anon_decl.deinit(); |
| 5674 | break :blk try anon_decl.finish( |
| 5675 | try operand.ty.copy(anon_decl.arena()), |
| 5676 | try operand.val.copy(anon_decl.arena()), |
| 5677 | 0, |
| 5678 | ); |
| 5679 | }, |
| 5672 | 5680 | }; |
| 5673 | 5681 | try sema.analyzeExport(block, src, options, decl_index); |
| 5674 | 5682 | } |
| ... | ... | @@ -5704,6 +5712,14 @@ pub fn analyzeExport( |
| 5704 | 5712 | return sema.failWithOwnedErrorMsg(msg); |
| 5705 | 5713 | } |
| 5706 | 5714 | |
| 5715 | // TODO: some backends might support re-exporting extern decls |
| 5716 | if (exported_decl.isExtern()) { |
| 5717 | return sema.fail(block, src, "export target cannot be extern", .{}); |
| 5718 | } |
| 5719 | |
| 5720 | // This decl is alive no matter what, since it's being exported |
| 5721 | mod.markDeclAlive(exported_decl); |
| 5722 | |
| 5707 | 5723 | const gpa = mod.gpa; |
| 5708 | 5724 | |
| 5709 | 5725 | try mod.decl_exports.ensureUnusedCapacity(gpa, 1); |