File tree Expand file tree Collapse file tree 3 files changed +55
-11
lines changed Expand file tree Collapse file tree 3 files changed +55
-11
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ fn (mut p Parser) if_expr(is_comptime bool) ast.IfExpr {
134
134
p.error ('use `\$ else` instead of `else` in compile-time `if` branches' )
135
135
return ast.IfExpr{}
136
136
}
137
- if p.peek_tok.kind == .key_else {
137
+ if p.tok.kind != .rcbr && p. peek_tok.kind == .key_else {
138
138
p.check (.dollar)
139
139
}
140
140
}
Original file line number Diff line number Diff line change
1
+ fn test_comptime_if_test () {
2
+ mut i := 0
3
+ $if test {
4
+ i++
5
+ }
6
+ $if ! test {
7
+ i--
8
+ }
9
+ assert i == 1
10
+ }
11
+
12
+ fn test_comptime_if_parsing_in_combination_with_ordinary_if_1 () {
13
+ if true {
14
+ $if debug {
15
+ println ('debug' )
16
+ }
17
+ } else {
18
+ assert false
19
+ }
20
+ assert true
21
+ }
22
+
23
+ fn test_comptime_if_parsing_in_combination_with_ordinary_if_2 () {
24
+ if true {
25
+ if true {
26
+ $if debug {
27
+ println ('debug' )
28
+ }
29
+ } else {
30
+ assert false
31
+ }
32
+ } else {
33
+ assert false
34
+ }
35
+ assert true
36
+ }
37
+
38
+ fn test_comptime_if_parsing_in_combination_with_ordinary_if_3 () {
39
+ println (@LINE)
40
+ $if true {
41
+ println (@LINE)
42
+ $if true {
43
+ println (@LINE)
44
+ $if debug {
45
+ println ('debug' )
46
+ }
47
+ } $else {
48
+ assert false
49
+ }
50
+ } $else {
51
+ assert false
52
+ }
53
+ assert true
54
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments