summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorVindaar <basti90@gmail.com>2022-12-08 10:59:13 +0100
committerGitHub <noreply@github.com>2022-12-08 10:59:13 +0100
commit0a1d4ba8427854306b89f4e91ed7902fb23adafb (patch)
treefe295a3e818c7dda3b60cf5d0f08a1cdd8a24fc5 /tests
parente669835665bd3b9ab600d1ce3502f4b643606175 (diff)
downloadNim-0a1d4ba8427854306b89f4e91ed7902fb23adafb.tar.gz
fix issue #20922 by handling missing expr in `exprList` for `tkOf` (#20930)
* fix issue #20922 by handling missing expr in `exprList` for `tkOf`

* fix line numbers in test case

* rewrite exprList requiring expr, add optionalExprList for except

As suggested by @metagn.

* update test case to reflect new code

* update grammar.txt

* update line numbers in test case taking into account nimout

Given the number of errors that are produced it seems easier to do it
this way instead of using `tt.Error`.
Diffstat (limited to 'tests')
-rw-r--r--tests/parser/t20922.nim46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/parser/t20922.nim b/tests/parser/t20922.nim
new file mode 100644
index 000000000..01af9868f
--- /dev/null
+++ b/tests/parser/t20922.nim
@@ -0,0 +1,46 @@
+discard """
+  cmd: "nim check $options --verbosity:0 $file"
+  action: "reject"
+  nimout: '''
+t20922.nim(37, 5) Error: expression expected, but found ':'
+Error: in expression ' '+'': identifier expected, but found ''
+t20922.nim(37, 7) Error: attempting to call undeclared routine: '<Error>'
+Error: in expression ' '+'': identifier expected, but found ''
+t20922.nim(37, 7) Error: attempting to call undeclared routine: '<Error>'
+t20922.nim(37, 7) Error: expression '' cannot be called
+t20922.nim(37, 7) Error: expression '' has no type (or is ambiguous)
+t20922.nim(37, 7) Error: VM problem: dest register is not set
+t20922.nim(45, 7) Error: expression expected, but found ':'
+t20922.nim(46, 5) Error: ':' or '=' expected, but got 'keyword of'
+t20922.nim(45, 9) Error: undeclared identifier: 'x'
+t20922.nim(45, 9) Error: expression 'x' has no type (or is ambiguous)
+Error: in expression ' x': identifier expected, but found ''
+t20922.nim(45, 9) Error: attempting to call undeclared routine: '<Error>'
+Error: in expression ' x': identifier expected, but found ''
+t20922.nim(45, 9) Error: attempting to call undeclared routine: '<Error>'
+t20922.nim(45, 9) Error: expression '' cannot be called
+t20922.nim(45, 9) Error: expression '' has no type (or is ambiguous)
+t20922.nim(45, 9) Error: VM problem: dest register is not set
+t20922.nim(33, 6) Hint: 'mapInstrToToken' is declared but not used [XDeclaredButNotUsed]
+t20922.nim(43, 3) Hint: 'Foo' is declared but not used [XDeclaredButNotUsed]
+'''
+"""
+# original test case issue #20922
+type Token = enum
+  incDataPtr,
+  incDataPtrByte
+
+proc mapInstrToToken(instr: char): Token =
+  case instr:
+  of '>':
+    incDataPtr
+  of: '+':
+    incDataPtrByte
+
+# same issue with `of` in object branches (different parser procs calling `exprList`)
+type
+  Bar = enum A, B
+  Foo = object
+    case kind: Bar
+    of: x: int
+    of B: y: float
0:27:22 -0400 committer Drew DeVault <sir@cmpwn.com> 2019-05-26 10:27:22 -0400 Subsitute prefix in aerc.conf for install' href='/akspecs/aerc/commit/Makefile?h=0.5.1&id=d30a6e3d1f1cf035d018ec27145ef57c4ce41606'>d30a6e3 ^
0bfb90b ^
58bc15b ^
fc719e4 ^

94b9d55 ^
fc719e4 ^

7a26b48 ^
4875813 ^
0016775 ^
58bc15b ^
3ba69ed ^

fc719e4 ^
0bfb90b ^








f42724c ^

d30a6e3 ^
fc719e4 ^
0bfb90b ^


fc719e4 ^
eabdcff ^
fc719e4 ^
3874269 ^
cd54bcd ^
3ba69ed ^
3874269 ^

94b9d55 ^
3874269 ^

7a26b48 ^
4875813 ^
0016775 ^
3874269 ^
c21ec37 ^
c5bc970 ^
7f540df ^
d30a6e3 ^
7f540df ^
177651b ^


3ba69ed ^

fc719e4 ^
d3b5a76 ^







6794ce0 ^
d3b5a76 ^

7a26b48 ^
4875813 ^
0016775 ^
d3b5a76 ^

6794ce0 ^
d3b5a76 ^






fc719e4 ^

d3b5a76 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109