Skip to content

Commit 1cffeb9

Browse files
committed
Customize it!
1 parent 43ab6ca commit 1cffeb9

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

src/stage2/Parse.zig

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ fn parseGlobalVarDecl(p: *Parse) !Node.Index {
873873

874874
p.nodes.items(.data)[var_decl].rhs = init_node;
875875

876-
try p.expectSemicolon(.expected_semi_after_decl, false);
876+
try p.expectSemicolon(.expected_semi_after_decl, true);
877877
return var_decl;
878878
}
879879

@@ -2963,7 +2963,14 @@ fn parsePrimaryTypeExpr(p: *Parse) !Node.Index {
29632963
},
29642964
}
29652965
},
2966-
else => return null_node,
2966+
else => return p.addNode(.{
2967+
.tag = .unreachable_literal,
2968+
.main_token = p.tok_i,
2969+
.data = .{
2970+
.lhs = undefined,
2971+
.rhs = undefined,
2972+
},
2973+
}),
29672974
},
29682975
.keyword_error => switch (p.token_tags[p.tok_i + 1]) {
29692976
.l_brace => {
@@ -3312,9 +3319,11 @@ fn expectFieldInit(p: *Parse) !Node.Index {
33123319
if (p.token_tags[p.tok_i] != .period or
33133320
p.token_tags[p.tok_i + 1] != .identifier or
33143321
p.token_tags[p.tok_i + 2] != .equal)
3315-
return p.fail(.expected_initializer);
3322+
{
3323+
try p.warn(.expected_initializer); // return p.fail(.expected_initializer);
3324+
p.tok_i += 1;
3325+
} else p.tok_i += 3;
33163326

3317-
p.tok_i += 3;
33183327
return p.expectExpr();
33193328
}
33203329

tests/lsp_features/completion.zig

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,16 @@ test "completion - generic function" {
105105
try testCompletion(
106106
\\const S = struct { alpha: u32 };
107107
\\fn foo(comptime T: type) T {}
108-
\\const s = foo(S);
109-
\\const foo = s.<cursor>
108+
\\const S1 = foo(S);
109+
\\const S2 = S1.<cursor>
110110
, &.{
111111
.{ .label = "alpha", .kind = .Field, .detail = "alpha: u32" },
112112
});
113113
try testCompletion(
114114
\\const S = struct { alpha: u32 };
115115
\\fn foo(any: anytype, comptime T: type) T {}
116-
\\const s = foo(null, S);
117-
\\const foo = s.<cursor>
116+
\\const S1 = foo(null, S);
117+
\\const S2 = S1.<cursor>
118118
, &.{
119119
.{ .label = "alpha", .kind = .Field, .detail = "alpha: u32" },
120120
});
@@ -1082,7 +1082,9 @@ test "completion - struct init" {
10821082
\\ brefa: A,
10831083
\\ this_is_b: []const u8,
10841084
\\};
1085-
\\ref(.{ .arefb = .{ .brefa = .{.<cursor>} } });
1085+
\\test {
1086+
\\ ref(.{ .arefb = .{ .brefa = .{.<cursor>} } });
1087+
\\}
10861088
, &.{
10871089
.{ .label = "arefb", .kind = .Field, .detail = "arefb: B = 8" },
10881090
.{ .label = "this_is_a", .kind = .Field, .detail = "this_is_a: u32 = 9" },
@@ -1121,7 +1123,9 @@ test "completion - struct init" {
11211123
\\ const Self = @This();
11221124
\\ pub fn s3(self: *Self, p0: es, p1: S2) void {}
11231125
\\};
1124-
\\S3.s3(null, .{ .mye = .{} }, .{ .ref1 = .{ .ref3 = .{ .ref2 = .{ .ref1 = .{.<cursor>} } } } });
1126+
\\test {
1127+
\\ S3.s3(null, .{ .mye = .{} }, .{ .ref1 = .{ .ref3 = .{ .ref2 = .{ .ref1 = .{.<cursor>} } } } });
1128+
\\}
11251129
, &.{
11261130
.{ .label = "s1f1", .kind = .Field, .detail = "s1f1: u8" },
11271131
.{ .label = "s1f2", .kind = .Field, .detail = "s1f2: u32 = 1" },
@@ -1147,8 +1151,10 @@ test "completion - struct init" {
11471151
\\ const Self = @This();
11481152
\\ pub fn s3(self: Self, p0: es, p1: S1) void {}
11491153
\\};
1150-
\\const iofs3 = S3{};
1151-
\\iofs3.s3(.{.<cursor>});
1154+
\\test {
1155+
\\ const iofs3 = S3{};
1156+
\\ iofs3.s3(.{.<cursor>});
1157+
\\}
11521158
, &.{
11531159
.{ .label = "s1f1", .kind = .Field, .detail = "s1f1: u8" },
11541160
.{ .label = "s1f2", .kind = .Field, .detail = "s1f2: u32 = 1" },

0 commit comments

Comments
 (0)