aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-07-22 17:15:15 +0300
committerVeikka Tuominen <git@vexu.eu>2022-07-23 15:40:12 +0300
commit881c0cb20b8cbde252ab38dff2c76886c4b72f1d (patch)
treeb373d7ace1576822b357f6ed5694065ecaa5523b /src/Module.zig
parent15dddfd84d9007689ef1fa6f4abedb88c570973a (diff)
downloadzig-881c0cb20b8cbde252ab38dff2c76886c4b72f1d.tar.gz
zig-881c0cb20b8cbde252ab38dff2c76886c4b72f1d.zip
Sema: add default value here note to invalid comptime field store error
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/Module.zig b/src/Module.zig
index da50fd9ae7..9c4ae69fe6 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -2704,6 +2704,18 @@ pub const SrcLoc = struct {
else => unreachable,
}
},
+ .node_offset_field_default => |node_off| {
+ const tree = try src_loc.file_scope.getTree(gpa);
+ const node_tags = tree.nodes.items(.tag);
+ const parent_node = src_loc.declRelativeToNodeIndex(node_off);
+
+ const full: Ast.full.ContainerField = switch (node_tags[parent_node]) {
+ .container_field => tree.containerField(parent_node),
+ .container_field_init => tree.containerFieldInit(parent_node),
+ else => unreachable,
+ };
+ return nodeToSpan(tree, full.ast.value_expr);
+ },
}
}
@@ -3021,6 +3033,9 @@ pub const LazySrcLoc = union(enum) {
/// The source location points to the tag type of an union or an enum.
/// The Decl is determined contextually.
node_offset_container_tag: i32,
+ /// The source location points to the default value of a field.
+ /// The Decl is determined contextually.
+ node_offset_field_default: i32,
pub const nodeOffset = if (TracedOffset.want_tracing) nodeOffsetDebug else nodeOffsetRelease;
@@ -3098,6 +3113,7 @@ pub const LazySrcLoc = union(enum) {
.node_offset_ptr_bitoffset,
.node_offset_ptr_hostsize,
.node_offset_container_tag,
+ .node_offset_field_default,
=> .{
.file_scope = decl.getFileScope(),
.parent_decl_node = decl.src_node,