this repo has no description
0
fork

Configure Feed

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

internal/core/adt: defensive use of CloseInfo

Passing CloseInfo in some cases where it doesn't seem to
be necessary.

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Ia3fc729fe951d227a05b9af40e6c4d49155af3f6
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/542831
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Paul Jolly <paul@myitcv.io>

+76 -13
+69 -8
cue/testdata/cycle/evaluate.txtar
··· 54 54 c: a 55 55 } 56 56 57 + listAddCycle: { 58 + a: b 59 + b: [c] + [c] 60 + c: a 61 + } 62 + 63 + listMulCycle: { 64 + a: b 65 + b: 3 + [{a: b: c}] 66 + c: a 67 + } 68 + 57 69 // consult the correct closeness info in the face of it being passed down 58 70 // from parent. 59 71 closeFail: { ··· 67 79 closeCycle.a: structural cycle 68 80 closeCycle.b.d: structural cycle 69 81 closeFail.x.b: field not allowed: 70 - ./in.cue:59:6 71 - ./in.cue:60:12 72 - ./in.cue:61:6 73 - ./in.cue:62:5 82 + ./in.cue:71:6 83 + ./in.cue:72:12 84 + ./in.cue:73:6 85 + ./in.cue:74:5 74 86 listCycle.0: structural cycle: 75 87 ./in.cue:17:9 76 88 disjunctionCycle.a: cannot use 1 (type int) as list in argument 1 to and: ··· 91 103 ./in.cue:46:9 92 104 embedCycle: structural cycle: 93 105 ./in.cue:52:11 106 + listAddCycle.0: structural cycle: 107 + ./in.cue:58:5 94 108 95 109 Result: 96 110 (_|_){ ··· 209 223 // ./in.cue:52:11 210 224 } 211 225 } 226 + listAddCycle: (_|_){ 227 + // [structural cycle] 228 + a: (_|_){ 229 + // [structural cycle] listAddCycle.0: structural cycle: 230 + // ./in.cue:58:5 231 + } 232 + b: (_|_){ 233 + // [structural cycle] listAddCycle.0: structural cycle: 234 + // ./in.cue:58:5 235 + } 236 + c: (_|_){ 237 + // [structural cycle] listAddCycle.0: structural cycle: 238 + // ./in.cue:58:5 239 + } 240 + } 241 + listMulCycle: (_|_){ 242 + // [structural cycle] 243 + a: (_|_){ 244 + // [structural cycle] 245 + } 246 + b: (_|_){ 247 + // [structural cycle] 248 + } 249 + c: (_|_){ 250 + // [structural cycle] 251 + } 252 + } 212 253 closeFail: (_|_){ 213 254 // [eval] 214 255 #T: (#struct){ ··· 219 260 a: (string){ string } 220 261 b: (_|_){ 221 262 // [eval] closeFail.x.b: field not allowed: 222 - // ./in.cue:59:6 223 - // ./in.cue:60:12 224 - // ./in.cue:61:6 225 - // ./in.cue:62:5 263 + // ./in.cue:71:6 264 + // ./in.cue:72:12 265 + // ./in.cue:73:6 266 + // ./in.cue:74:5 226 267 } 227 268 } 228 269 } ··· 288 329 b: close({ 289 330 〈1;c〉 290 331 }) 332 + c: 〈0;a〉 333 + } 334 + listAddCycle: { 335 + a: 〈0;b〉 336 + b: ([ 337 + 〈1;c〉, 338 + ] + [ 339 + 〈1;c〉, 340 + ]) 341 + c: 〈0;a〉 342 + } 343 + listMulCycle: { 344 + a: 〈0;b〉 345 + b: (3 + [ 346 + { 347 + a: { 348 + b: 〈3;c〉 349 + } 350 + }, 351 + ]) 291 352 c: 〈0;a〉 292 353 } 293 354 closeFail: {
+2 -2
internal/core/adt/binop.go
··· 205 205 } 206 206 207 207 n := &Vertex{} 208 - n.AddConjunct(MakeRootConjunct(c.Env(0), list)) 208 + n.AddConjunct(MakeConjunct(c.Env(0), list, c.ci)) 209 209 n.Finalize(c) 210 210 211 211 return n ··· 266 266 } 267 267 268 268 n := &Vertex{} 269 - n.AddConjunct(MakeRootConjunct(c.Env(0), list)) 269 + n.AddConjunct(MakeConjunct(c.Env(0), list, c.ci)) 270 270 n.Finalize(c) 271 271 272 272 return n
+2
internal/core/adt/context.go
··· 255 255 inConstraint int 256 256 } 257 257 258 + func (c *OpContext) CloseInfo() CloseInfo { return c.ci } 259 + 258 260 func (n *nodeContext) skipNonMonotonicChecks() bool { 259 261 if n.ctx.inConstraint > 0 { 260 262 return false
+1 -2
internal/core/adt/eval.go
··· 2018 2018 2019 2019 for _, a := range elems { 2020 2020 if a.Conjuncts == nil { 2021 - x := a.BaseValue.(Value) 2022 - n.insertField(a.Label, MakeRootConjunct(nil, x)) 2021 + n.insertField(a.Label, MakeRootConjunct(nil, a)) 2023 2022 continue 2024 2023 } 2025 2024 for _, c := range a.Conjuncts {
+2 -1
internal/core/compile/builtin.go
··· 137 137 } 138 138 v := &adt.Vertex{} 139 139 // TODO: make a Disjunction. 140 - v.AddConjunct(adt.MakeRootConjunct(nil, 140 + v.AddConjunct(adt.MakeConjunct(nil, 141 141 &adt.DisjunctionExpr{Values: d, HasDefaults: false}, 142 + c.CloseInfo(), 142 143 )) 143 144 c.Unify(v, adt.Finalized) 144 145 return v