diff options
| author | Mitchell Hashimoto <m@mitchellh.com> | 2024-11-27 08:46:03 -0800 |
|---|---|---|
| committer | Mitchell Hashimoto <m@mitchellh.com> | 2024-11-27 08:46:47 -0800 |
| commit | 5b01cb353de47a0053c313e3bc20170cbece679e (patch) | |
| tree | ca0b99796f8213c9215496500afd051413fc0757 /src/cli/diagnostics.zig | |
| parent | 466d094c18729fc49501f48dc6b283aed72362af (diff) | |
config: need to dupe filepath for diagnostics
Fixes #2800
The source string with the filepath is not guaranteed to exist beyond
the lifetime of the parse operation. We must copy it.
Diffstat (limited to 'src/cli/diagnostics.zig')
| -rw-r--r-- | src/cli/diagnostics.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cli/diagnostics.zig b/src/cli/diagnostics.zig index 8090684fd..40fed3001 100644 --- a/src/cli/diagnostics.zig +++ b/src/cli/diagnostics.zig @@ -56,7 +56,7 @@ pub const Location = union(enum) { pub const Key = @typeInfo(Location).Union.tag_type.?; - pub fn fromIter(iter: anytype) Location { + pub fn fromIter(iter: anytype, alloc: Allocator) Allocator.Error!Location { const Iter = t: { const T = @TypeOf(iter); break :t switch (@typeInfo(T)) { @@ -67,7 +67,7 @@ pub const Location = union(enum) { }; if (!@hasDecl(Iter, "location")) return .none; - return iter.location() orelse .none; + return (try iter.location(alloc)) orelse .none; } pub fn clone(self: *const Location, alloc: Allocator) Allocator.Error!Location { |
