Skip to content

Commit 28489a2

Browse files
committed
fix position context on single character number literal
1 parent 36982fd commit 28489a2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/analysis.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3488,7 +3488,10 @@ pub fn getPositionContext(
34883488
// `tok` is the latter of the two.
34893489
if (!should_do_lookahead) break;
34903490
switch (tok.tag) {
3491-
.identifier, .builtin => should_do_lookahead = false,
3491+
.identifier,
3492+
.builtin,
3493+
.number_literal,
3494+
=> should_do_lookahead = false,
34923495
else => break,
34933496
}
34943497
}

tests/utility/position_context.zig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,24 @@ test "global error set" {
354354
// , .global_error_set, .{});
355355
}
356356

357+
test "number literal" {
358+
try testContext(
359+
\\var foo = <loc>5<cursor></loc>;
360+
, .number_literal, .{});
361+
try testContext(
362+
\\var foo = <loc><cursor>5</loc>;
363+
, .number_literal, .{ .lookahead = true });
364+
}
365+
366+
test "char literal" {
367+
try testContext(
368+
\\var foo = <loc>'5<cursor>'</loc>;
369+
, .char_literal, .{ .lookahead = true });
370+
try testContext(
371+
\\var foo = <loc>'<cursor>5'</loc>;
372+
, .char_literal, .{ .lookahead = true });
373+
}
374+
357375
test "enum literal" {
358376
try testContext(
359377
\\var foo = <loc>.<cursor>tag</loc>;

0 commit comments

Comments
 (0)