| ... | @@ -13143,6 +13143,36 @@ fn zirClosureGet( | ... | @@ -13143,6 +13143,36 @@ fn zirClosureGet( |
| 13143 | scope = scope.parent.?; | 13143 | scope = scope.parent.?; |
| 13144 | } else unreachable; | 13144 | } else unreachable; |
| 13145 | | 13145 | |
| | 13146 | if (tv.val.tag() == .generic_poison and !block.is_typeof and !block.is_comptime and sema.func != null) { |
| | 13147 | const msg = msg: { |
| | 13148 | const name = name: { |
| | 13149 | const file = sema.owner_decl.getFileScope(); |
| | 13150 | const tree = file.getTree(sema.mod.gpa) catch |err| { |
| | 13151 | // In this case we emit a warning + a less precise source location. |
| | 13152 | log.warn("unable to load {s}: {s}", .{ |
| | 13153 | file.sub_file_path, @errorName(err), |
| | 13154 | }); |
| | 13155 | break :name null; |
| | 13156 | }; |
| | 13157 | const node = sema.owner_decl.relativeToNodeIndex(inst_data.src_node); |
| | 13158 | const token = tree.nodes.items(.main_token)[node]; |
| | 13159 | break :name tree.tokenSlice(token); |
| | 13160 | }; |
| | 13161 | |
| | 13162 | const msg = if (name) |some| |
| | 13163 | try sema.errMsg(block, inst_data.src(), "'{s}' not accessible from inner function", .{some}) |
| | 13164 | else |
| | 13165 | try sema.errMsg(block, inst_data.src(), "variable not accessible from inner function", .{}); |
| | 13166 | errdefer msg.destroy(sema.gpa); |
| | 13167 | |
| | 13168 | try sema.errNote(block, LazySrcLoc.nodeOffset(0), msg, "crossed function definition here", .{}); |
| | 13169 | |
| | 13170 | // TODO add "declared here" note |
| | 13171 | break :msg msg; |
| | 13172 | }; |
| | 13173 | return sema.failWithOwnedErrorMsg(block, msg); |
| | 13174 | } |
| | 13175 | |
| 13146 | return sema.addConstant(tv.ty, tv.val); | 13176 | return sema.addConstant(tv.ty, tv.val); |
| 13147 | } | 13177 | } |
| 13148 | | 13178 | |