summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJasper Jenkins <jasper.vs.jenkins@gmail.com>2019-05-26 22:59:22 -0700
committerAndreas Rumpf <rumpf_a@web.de>2019-05-27 07:59:22 +0200
commit1286ba34529d37432c146f73f24cc873ccd6adac (patch)
treeea8bd493e33a906f74bc5b26e3375f97afc28257
parentf7744260959bbdaefdc5172aaf7ff4770f8f8c03 (diff)
downloadNim-1286ba34529d37432c146f73f24cc873ccd6adac.tar.gz
fix bool and range (#11336)
-rw-r--r--compiler/semobjconstr.nim10
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/semobjconstr.nim b/compiler/semobjconstr.nim
index 1597faa70..4b4c5de02 100644
--- a/compiler/semobjconstr.nim
+++ b/compiler/semobjconstr.nim
@@ -95,7 +95,8 @@ template processBranchVals(b, op) =
 
 proc allPossibleValues(c: PContext, t: PType): IntSet =
   result = initIntSet()
-  if t.kind == tyEnum:
+  if t.enumHasHoles:
+    let t = t.skipTypes(abstractRange)
     for field in t.n.sons:
       result.incl(field.sym.position)
   else:
@@ -112,10 +113,11 @@ proc branchVals(c: PContext, caseNode: PNode, caseIdx: int,
     for i in 1 .. caseNode.len-2:
       processBranchVals(caseNode[i], excl)
 
-proc formatUnsafeBranchVals(c: PContext, t: PType, diffVals: IntSet): string =
+proc formatUnsafeBranchVals(t: PType, diffVals: IntSet): string =
   if diffVals.len <= 32:
     var strs: seq[string]
-    if t.kind == tyEnum:
+    let t = t.skipTypes(abstractRange)
+    if t.kind in {tyEnum, tyBool}:
       var i = 0
       for val in diffVals:
         while t.n.sons[i].sym.position < val: inc(i)
@@ -272,7 +274,7 @@ proc semConstructFields(c: PContext, recNode: PNode,
             localError(c.config, discriminatorVal.info, ("possible values " &
               "$2are in conflict with discriminator values for " &
               "selected object branch $1.") % [$selectedBranch,
-              formatUnsafeBranchVals(c, recNode.sons[0].typ, branchValsDiff)])
+              formatUnsafeBranchVals(recNode.sons[0].typ, branchValsDiff)])
       else:
         if branchNode.kind != nkElse:
           if not branchNode.caseBranchMatchesExpr(discriminatorVal):
b.de> 2015-02-08 15:43:50 +0100 fixes #2004' href='/ahoang/Nim/commit/tests/template/tparams_gensymed.nim?h=devel&id=34b4e9fc9624042d9fb94a73535baa76b3033376'>34b4e9fc9 ^
f2cdbc92e ^



97e26967f ^
f2cdbc92e ^






000b8afd2 ^
f2cdbc92e ^














e87470597 ^







































2475d92c3 ^



















b07694cd9 ^













7ef85db9a ^













58bcf6cd4 ^





























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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197