this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: exclude more cases for adding defID

Previously, we only excluded defIDs for conjuncts
if they were not within the same OpID.
We, however, need to exclude the addition
of any OpID

Issue #4000

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I4cc0e36098fc7f6e3c78811a310eb7daff78e2cc
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1219237
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>

+110 -155
+95 -144
cue/testdata/definitions/issue4000.txtar
··· 32 32 #TypeMeta: kind: string | *"default" 33 33 -- out/evalalpha -- 34 34 Errors: 35 - items: error in call to list.Sort: runtime error: index out of range [13] with length 8: 35 + items: error in call to list.Sort: runtime error: index out of range [13] with length 6: 36 36 ./in.cue:3:8 37 37 38 38 Result: 39 39 (_|_){ 40 40 // [eval] 41 41 items: (_|_){ 42 - // [eval] items: error in call to list.Sort: runtime error: index out of range [13] with length 8: 42 + // [eval] items: error in call to list.Sort: runtime error: index out of range [13] with length 6: 43 43 // ./in.cue:3:8 44 44 } 45 45 #List: (#struct){ ··· 169 169 +++ new 170 170 @@ -1,9 +1,11 @@ 171 171 Leaks: 0 172 - -Freed: 159 173 - -Reused: 147 174 - -Allocs: 12 175 - -Retain: 6 172 + -Freed: 152 173 + -Reused: 137 174 + -Allocs: 15 175 + -Retain: 9 176 176 - 177 - -Unifications: 135 178 - -Conjuncts: 273 179 - -Disjuncts: 165 177 + -Unifications: 116 178 + -Conjuncts: 257 179 + -Disjuncts: 161 180 180 +Freed: 52 181 181 +Reused: 20 182 182 +Allocs: 32 ··· 201 201 diff old new 202 202 --- old 203 203 +++ new 204 - @@ -1,103 +1,62 @@ 204 + @@ -1,85 +1,22 @@ 205 205 -(struct){ 206 206 - items: (#list){ 207 - +Errors: 208 - +items: error in call to list.Sort: runtime error: index out of range [13] with length 8: 209 - + ./in.cue:3:8 210 - + 211 - +Result: 212 - +(_|_){ 213 - + // [eval] 214 - + items: (_|_){ 215 - + // [eval] items: error in call to list.Sort: runtime error: index out of range [13] with length 8: 216 - + // ./in.cue:3:8 217 - + } 218 - + #List: (#struct){ 219 - + items: (#list){ 220 - + 0: ~(#VMRuleList.0) 221 - + 1: ~(#VMRuleList.1) 222 - + } 223 - + } 224 - + _items: (#list){ 225 - + 0: ~(#VMRuleList) 226 - + } 227 - + #VMRuleList: (#list){ 228 - 0: (#struct){ 229 - - kind: (string){ "1_first" } 230 - - rules: (#list){ 207 + - 0: (#struct){ 208 + - spec: (#list){ 231 209 - 0: (#struct){ 232 - - expr: (string){ "c" } 233 - - } 234 - - 1: (#struct){ 235 - - expr: (string){ "d" } 210 + - rules: (#list){ 211 + - 0: (#struct){ 212 + - expr: (string){ "x" } 213 + - } 214 + - } 236 215 - } 237 216 - } 217 + - kind: (string){ |(*(string){ "default" }, (string){ string }) } 238 218 - } 239 219 - 1: (#struct){ 240 - - kind: (string){ "2_second" } 241 - - rules: (#list){ 220 + - spec: (#list){ 242 221 - 0: (#struct){ 243 - - expr: (string){ "a" } 244 - - } 245 - - 1: (#struct){ 246 - - expr: (string){ "b" } 222 + - rules: (#list){ 223 + - 0: (#struct){ 224 + - expr: (string){ "y" } 225 + - } 226 + - } 247 227 - } 248 228 - } 229 + - kind: (string){ |(*(string){ "default" }, (string){ string }) } 249 230 - } 250 - - 2: (#struct){ |(*(struct){ 251 - - kind: (string){ "9_last" } 252 - - }, (#struct){ 253 - - kind!: (string){ string } 254 - - rules?: (list){ 255 - - } 256 - - }) } 257 - - } 258 - - #GroupListAgain: (#list){ 259 - - 0: (#struct){ |(*(#struct){ 260 - - kind: (string){ "9_last" } 261 - - }, (#struct){ 262 - - kind!: (string){ string } 263 - - rules?: (list){ 264 - - } 265 - - }) } 266 - - 1: (#struct){ 267 - - kind: (string){ "2_second" } 268 - - rules: (#list){ 269 - - 0: (#struct){ 270 - - expr: (string){ "a" } 271 - - } 272 - - 1: (#struct){ 273 - - expr: (string){ "b" } 231 + +Errors: 232 + +items: error in call to list.Sort: runtime error: index out of range [13] with length 6: 233 + + ./in.cue:3:8 234 + + 235 + +Result: 236 + +(_|_){ 237 + + // [eval] 238 + + items: (_|_){ 239 + + // [eval] items: error in call to list.Sort: runtime error: index out of range [13] with length 6: 240 + + // ./in.cue:3:8 241 + } 242 + #List: (#struct){ 243 + items: (#list){ 244 + - 0: (#struct){ 245 + - spec: (#list){ 246 + - 0: (#struct){ 247 + - rules: (#list){ 248 + - 0: (#struct){ 249 + - expr: (string){ "x" } 250 + - } 251 + - } 252 + - } 274 253 - } 254 + - kind: (string){ |(*(string){ "default" }, (string){ string }) } 275 255 - } 276 - - } 277 - - 2: (#struct){ 278 - - kind: (string){ "1_first" } 279 - - rules: (#list){ 280 - - 0: (#struct){ 281 - - expr: (string){ "c" } 256 + - 1: (#struct){ 257 + - spec: (#list){ 258 + - 0: (#struct){ 259 + - rules: (#list){ 260 + - 0: (#struct){ 261 + - expr: (string){ "y" } 262 + - } 263 + - } 264 + - } 282 265 - } 283 - - 1: (#struct){ 284 - - expr: (string){ "d" } 285 - - } 266 + - kind: (string){ |(*(string){ "default" }, (string){ string }) } 286 267 - } 287 - - } 288 - - } 289 - - #GroupList: (#list){ 290 - - 0: (#struct){ |(*(#struct){ 291 - - kind: (string){ "9_last" } 292 - - }, (#struct){ 293 - - kind!: (string){ string } 294 - - rules?: (list){ 295 - - } 296 - - }) } 297 - - 1: (#struct){ 298 - - kind: (string){ "2_second" } 299 - - rules: (#list){ 300 - - 0: (#struct){ 301 - - expr: (string){ "a" } 302 - - } 303 - - 1: (#struct){ 304 - - expr: (string){ "b" } 268 + + 0: ~(#VMRuleList.0) 269 + + 1: ~(#VMRuleList.1) 270 + } 271 + } 272 + _items: (#list){ 273 + - 0: (#list){ 274 + - 0: (#struct){ 275 + - spec: (#list){ 276 + - 0: (#struct){ 277 + - rules: (#list){ 278 + - 0: (#struct){ 279 + - expr: (string){ "x" } 280 + - } 281 + - } 282 + - } 305 283 - } 284 + - kind: (string){ |(*(string){ "default" }, (string){ string }) } 306 285 - } 307 - - } 308 - - 2: (#struct){ 309 - - kind: (string){ "1_first" } 310 - - rules: (#list){ 311 - - 0: (#struct){ 312 - - expr: (string){ "c" } 286 + - 1: (#struct){ 287 + - spec: (#list){ 288 + - 0: (#struct){ 289 + - rules: (#list){ 290 + - 0: (#struct){ 291 + - expr: (string){ "y" } 292 + - } 293 + - } 294 + - } 313 295 - } 314 - - 1: (#struct){ 315 - - expr: (string){ "d" } 316 - - } 296 + - kind: (string){ |(*(string){ "default" }, (string){ string }) } 317 297 - } 318 298 - } 319 - - } 320 - - #Group: (#struct){ 321 - - kind!: (string){ string } 322 - - rules?: (list){ 323 - + spec: (#list){ 324 - + 0: (#struct){ 325 - + rules: (#list){ 326 - + 0: (#struct){ 327 - + expr: (string){ "x" } 328 - + } 329 - + } 330 - + } 331 - + } 332 - + kind: (string){ |(*(string){ "default" }, (string){ string }) } 333 - + } 334 - + 1: (#struct){ 335 - + spec: (#list){ 336 - + 0: (#struct){ 337 - + rules: (#list){ 338 - + 0: (#struct){ 339 - + expr: (string){ "y" } 340 - + } 341 - + } 342 - + } 343 - + } 344 - + kind: (string){ |(*(string){ "default" }, (string){ string }) } 345 - + } 346 - + } 347 - + #RuleGroup: (#struct){ 348 - + rules: (list){ 349 - } 299 + + 0: ~(#VMRuleList) 350 300 } 351 - #Rule: (#struct){ 301 + #VMRuleList: (#list){ 302 + 0: (#struct){ 303 + @@ -115,9 +52,9 @@ 352 304 expr: (string){ string } 353 305 } 354 - + #VMRule: (#struct){ 355 - + spec: (list){ 356 - + } 357 - + kind: (string){ |(*(string){ "default" }, (string){ string }) } 358 - + } 359 - + #TypeMeta: (#struct){ 306 + #VMRule: (#struct){ 307 + - kind: (string){ |(*(string){ "default" }, (string){ string }) } 308 + spec: (list){ 309 + } 360 310 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 361 - + } 362 - } 311 + } 312 + #TypeMeta: (#struct){ 313 + kind: (string){ |(*(string){ "default" }, (string){ string }) } 363 314 -- out/eval -- 364 315 (struct){ 365 316 items: (#list){
+5 -8
internal/core/adt/conjunct.go
··· 362 362 default: 363 363 closeInfo = n.addResolver(arc, closeInfo, true) 364 364 } 365 - if closeInfo.defID != 0 && closeInfo.opID != n.ctx.opID { 366 - // Since the closeInfo is local, this should never happen. 367 - panic("opID mismatch: " + 368 - fmt.Sprintf("%#v != %#v", closeInfo.opID, n.ctx.opID)) 365 + if closeInfo.defID != 0 && closeInfo.opID == n.ctx.opID { 366 + c.CloseInfo.opID = closeInfo.opID 367 + c.CloseInfo.defID = closeInfo.defID 368 + c.CloseInfo.outerID = closeInfo.outerID 369 + c.CloseInfo.enclosingEmbed = closeInfo.enclosingEmbed 369 370 } 370 - c.CloseInfo.opID = closeInfo.opID 371 - c.CloseInfo.defID = closeInfo.defID 372 - c.CloseInfo.outerID = closeInfo.outerID 373 - c.CloseInfo.enclosingEmbed = closeInfo.enclosingEmbed 374 371 375 372 key := arcKey{arc, ciKey} 376 373 for _, k := range n.arcMap {
+10 -3
internal/core/adt/typocheck.go
··· 325 325 return id 326 326 } 327 327 328 + if id.opID != 0 && id.opID != n.ctx.opID { 329 + return id 330 + } 331 + 328 332 closeOuter := (id.FromDef && id.FromEmbed) || v.ClosedNonRecursive 329 333 330 334 if closeOuter && !forceIgnore { ··· 688 692 // that we can use this to bail out early. 689 693 c := n.ctx 690 694 c.redirectsBuf = c.redirectsBuf[:0] 691 - for n := n; n != nil; n = n.node.Parent.state { 692 - c.redirectsBuf = append(c.redirectsBuf, n.replaceIDs...) 693 - if n.node.Parent == nil { 695 + for p := n; p != nil; p = p.node.Parent.state { 696 + if p.opID != n.opID { 697 + break 698 + } 699 + c.redirectsBuf = append(c.redirectsBuf, p.replaceIDs...) 700 + if p.node.Parent == nil { 694 701 break 695 702 } 696 703 }