| ... | @@ -5312,7 +5312,14 @@ fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -5312,7 +5312,14 @@ fn zirDeclRef(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 5312 | const src = inst_data.src(); | 5312 | const src = inst_data.src(); |
| 5313 | const decl_name = inst_data.get(sema.code); | 5313 | const decl_name = inst_data.get(sema.code); |
| 5314 | const decl_index = try sema.lookupIdentifier(block, src, decl_name); | 5314 | const decl_index = try sema.lookupIdentifier(block, src, decl_name); |
| 5315 | return sema.analyzeDeclRef(decl_index); | 5315 | return sema.analyzeDeclRef(decl_index) catch |err| switch (err) { |
| | 5316 | error.AnalysisFail => { |
| | 5317 | const msg = sema.err orelse return err; |
| | 5318 | try sema.errNote(block, src, msg, "referenced here", .{}); |
| | 5319 | return err; |
| | 5320 | }, |
| | 5321 | else => return err, |
| | 5322 | }; |
| 5316 | } | 5323 | } |
| 5317 | | 5324 | |
| 5318 | fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { | 5325 | fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { |
| ... | @@ -20876,7 +20883,14 @@ fn namespaceLookupRef( | ... | @@ -20876,7 +20883,14 @@ fn namespaceLookupRef( |
| 20876 | decl_name: []const u8, | 20883 | decl_name: []const u8, |
| 20877 | ) CompileError!?Air.Inst.Ref { | 20884 | ) CompileError!?Air.Inst.Ref { |
| 20878 | const decl = (try sema.namespaceLookup(block, src, namespace, decl_name)) orelse return null; | 20885 | const decl = (try sema.namespaceLookup(block, src, namespace, decl_name)) orelse return null; |
| 20879 | return try sema.analyzeDeclRef(decl); | 20886 | return sema.analyzeDeclRef(decl) catch |err| switch (err) { |
| | 20887 | error.AnalysisFail => { |
| | 20888 | const msg = sema.err orelse return err; |
| | 20889 | try sema.errNote(block, src, msg, "referenced here", .{}); |
| | 20890 | return err; |
| | 20891 | }, |
| | 20892 | else => return err, |
| | 20893 | }; |
| 20880 | } | 20894 | } |
| 20881 | | 20895 | |
| 20882 | fn namespaceLookupVal( | 20896 | fn namespaceLookupVal( |
| ... | @@ -24979,7 +24993,14 @@ fn analyzeDeclVal( | ... | @@ -24979,7 +24993,14 @@ fn analyzeDeclVal( |
| 24979 | if (sema.decl_val_table.get(decl_index)) |result| { | 24993 | if (sema.decl_val_table.get(decl_index)) |result| { |
| 24980 | return result; | 24994 | return result; |
| 24981 | } | 24995 | } |
| 24982 | const decl_ref = try sema.analyzeDeclRef(decl_index); | 24996 | const decl_ref = sema.analyzeDeclRef(decl_index) catch |err| switch (err) { |
| | 24997 | error.AnalysisFail => { |
| | 24998 | const msg = sema.err orelse return err; |
| | 24999 | try sema.errNote(block, src, msg, "referenced here", .{}); |
| | 25000 | return err; |
| | 25001 | }, |
| | 25002 | else => return err, |
| | 25003 | }; |
| 24983 | const result = try sema.analyzeLoad(block, src, decl_ref, src); | 25004 | const result = try sema.analyzeLoad(block, src, decl_ref, src); |
| 24984 | if (Air.refToIndex(result)) |index| { | 25005 | if (Air.refToIndex(result)) |index| { |
| 24985 | if (sema.air_instructions.items(.tag)[index] == .constant and !block.is_typeof) { | 25006 | if (sema.air_instructions.items(.tag)[index] == .constant and !block.is_typeof) { |
| ... | @@ -24990,6 +25011,12 @@ fn analyzeDeclVal( | ... | @@ -24990,6 +25011,12 @@ fn analyzeDeclVal( |
| 24990 | } | 25011 | } |
| 24991 | | 25012 | |
| 24992 | fn ensureDeclAnalyzed(sema: *Sema, decl_index: Decl.Index) CompileError!void { | 25013 | fn ensureDeclAnalyzed(sema: *Sema, decl_index: Decl.Index) CompileError!void { |
| | 25014 | const decl = sema.mod.declPtr(decl_index); |
| | 25015 | if (decl.analysis == .in_progress) { |
| | 25016 | const msg = try Module.ErrorMsg.create(sema.gpa, decl.srcLoc(), "dependency loop detected", .{}); |
| | 25017 | return sema.failWithOwnedErrorMsg(msg); |
| | 25018 | } |
| | 25019 | |
| 24993 | sema.mod.ensureDeclAnalyzed(decl_index) catch |err| { | 25020 | sema.mod.ensureDeclAnalyzed(decl_index) catch |err| { |
| 24994 | if (sema.owner_func) |owner_func| { | 25021 | if (sema.owner_func) |owner_func| { |
| 24995 | owner_func.state = .dependency_failure; | 25022 | owner_func.state = .dependency_failure; |