authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-12-28 16:41:51-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-01-15 15:11:36-08:00
log78987081ce84a49230073e8211dadc0dea7351c3
treef1b38cc2a51186bccd249c06e7036700292b381d
parenta72e7384aae81d012f017c837df8c16048bdea4e

can't use source location until return from this function


1 files changed, 11 insertions(+), 11 deletions(-)

src/link/Wasm/Object.zig+11-11
......@@ -696,10 +696,10 @@ pub fn parse(
696696 exp.* = .{
697697 .name = try wasm.internString(name),
698698 .pointee = switch (kind) {
699 .function => .{ .function = @enumFromInt(functions_start + index) },
699 .function => .{ .function = @enumFromInt(functions_start + (index - ss.func_imports.items.len)) },
700700 .table => .{ .table = @enumFromInt(tables_start + index) },
701701 .memory => .{ .memory = @enumFromInt(memories_start + index) },
702 .global => .{ .global = @enumFromInt(globals_start + index) },
702 .global => .{ .global = @enumFromInt(globals_start + (index - ss.global_imports.items.len)) },
703703 },
704704 };
705705 }
......@@ -827,7 +827,7 @@ pub fn parse(
827827 gop.value_ptr.source_location.addNote(wasm, &err, "imported as {} here", .{
828828 gop.value_ptr.type.fmt(wasm),
829829 });
830 source_location.addNote(wasm, &err, "imported as {} here", .{fn_ty_index.fmt(wasm)});
830 err.addNote("{}: imported as {} here", .{ path, fn_ty_index.fmt(wasm) });
831831 continue;
832832 }
833833 if (gop.value_ptr.module_name != ptr.module_name.toOptional()) {
......@@ -838,7 +838,7 @@ pub fn parse(
838838 } else {
839839 gop.value_ptr.source_location.addNote(wasm, &err, "no module here", .{});
840840 }
841 source_location.addNote(wasm, &err, "module '{s}' here", .{ptr.module_name.slice(wasm)});
841 err.addNote("{}: module '{s}' here", .{ path, ptr.module_name.slice(wasm) });
842842 continue;
843843 }
844844 if (symbol.flags.binding == .strong) gop.value_ptr.flags.binding = .strong;
......@@ -868,7 +868,7 @@ pub fn parse(
868868 var err = try diags.addErrorWithNotes(2);
869869 try err.addMsg("symbol '{s}' mismatching global types", .{name.slice(wasm)});
870870 gop.value_ptr.source_location.addNote(wasm, &err, "type {s} here", .{@tagName(existing_ty.valtype)});
871 source_location.addNote(wasm, &err, "type {s} here", .{@tagName(ptr.valtype)});
871 err.addNote("{}: type {s} here", .{ path, @tagName(ptr.valtype) });
872872 continue;
873873 }
874874 if (ptr.mutable != existing_ty.mutable) {
......@@ -877,8 +877,8 @@ pub fn parse(
877877 gop.value_ptr.source_location.addNote(wasm, &err, "{s} here", .{
878878 if (existing_ty.mutable) "mutable" else "not mutable",
879879 });
880 source_location.addNote(wasm, &err, "{s} here", .{
881 if (ptr.mutable) "mutable" else "not mutable",
880 err.addNote("{}: {s} here", .{
881 path, if (ptr.mutable) "mutable" else "not mutable",
882882 });
883883 continue;
884884 }
......@@ -890,7 +890,7 @@ pub fn parse(
890890 } else {
891891 gop.value_ptr.source_location.addNote(wasm, &err, "no module here", .{});
892892 }
893 source_location.addNote(wasm, &err, "module '{s}' here", .{ptr.module_name.slice(wasm)});
893 err.addNote("{}: module '{s}' here", .{ path, ptr.module_name.slice(wasm) });
894894 continue;
895895 }
896896 if (symbol.flags.binding == .strong) gop.value_ptr.flags.binding = .strong;
......@@ -925,7 +925,7 @@ pub fn parse(
925925 ptr.type_index.fmt(wasm),
926926 });
927927 const word = if (gop.value_ptr.resolution == .unresolved) "imported" else "exported";
928 source_location.addNote(wasm, &err, "{s} as {} here", .{ word, gop.value_ptr.type.fmt(wasm) });
928 err.addNote("{}: {s} as {} here", .{ path, word, gop.value_ptr.type.fmt(wasm) });
929929 continue;
930930 }
931931 if (gop.value_ptr.resolution == .unresolved or gop.value_ptr.flags.binding == .weak) {
......@@ -938,7 +938,7 @@ pub fn parse(
938938 var err = try diags.addErrorWithNotes(2);
939939 try err.addMsg("symbol collision: {s}", .{name.slice(wasm)});
940940 gop.value_ptr.source_location.addNote(wasm, &err, "exported as {} here", .{ptr.type_index.fmt(wasm)});
941 source_location.addNote(wasm, &err, "exported as {} here", .{gop.value_ptr.type.fmt(wasm)});
941 err.addNote("{}: exported as {} here", .{ path, gop.value_ptr.type.fmt(wasm) });
942942 continue;
943943 } else {
944944 gop.value_ptr.* = .{
......@@ -993,7 +993,7 @@ pub fn parse(
993993 inline .function, .table, .memory, .global => |index| {
994994 const ptr = index.ptr(wasm);
995995 if (ptr.name == .none) {
996 // Missng symbol table entry; use defaults for exported things.
996 // Missing symbol table entry; use defaults for exported things.
997997 ptr.name = exp.name.toOptional();
998998 ptr.flags.exported = true;
999999 }