this repo has no description
0
fork

Configure Feed

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

internal/core/adt: pass and use OpContext to functions using Schema

Builtins that have a pkg.Schema argument evaluate this
argument as an expression, possibly unifying it with
something else. This may result in a cycle.

In order to detect the cycle, the cycle information
obtained from using the argument must passed to
further evaluation. We do this by making the Schema
method call CallContext.Expr, which, in turn, uses
EvaluatedKeepState to accumulate cycle information
in the OpContext.

The functions that are passed the OpContext then
need to use adt.Unify instead of Value.Unify to be able to
detect cycles.

NOTE: this strongly hints that we need to change the
public API to also be centered around an operation
context. This has come up in various situations already.

This change requires pkg/gen.go to also pass an
OpContext for the generated stubs. We take a somewhat
unusual approach here: rather than changing the functions
to take an OpContext, we instead call a non-exported
function with the OpContext added as the first argument
whenever an Exported function with a pkg.Schema
argument is found.

The reason for this is that we currently piggyback on
godoc to generate documentation for the builtins.
Adding the OpContext in this signature would be
confusing for the the user, as it should not be
populated in CUE.

Note some counter error were introduced
by the new tests.

The error messages have some additional or longer
paths as a result of this change, which is either a
benign change or desirable.

Fixes #3649
(fixes derivative issues, was already closed)

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I4b5a31aeb5501ec03915d069f8b92f56311124dd
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1208702
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Matthew Sackman <matthew@cue.works>

+912 -354
+849 -340
cue/testdata/cycle/builtins.txtar
··· 134 134 #s: matchN(1, [matchN(1, [{a!: _}])]) 135 135 } 136 136 -- cycle.cue -- 137 - import "encoding/yaml" 138 - 139 137 noCycle: t1: { 140 138 _s 141 139 _s: { ··· 169 167 a: matchN(1, [#c]) 170 168 } 171 169 } 170 + -- yamlcycle.cue -- 171 + import "encoding/yaml" 172 + 172 173 yamlNoCycle: { 173 174 // the validator is invoked recursively and also unifies with a concrete 174 175 // value. This should nonetheless not result in a cycle error. ··· 189 190 c: matchN(1, [{d: c}]) 190 191 c: {} 191 192 } 192 - // TODO: fix hang 193 - // selfCycle: yamlVal: t1: { 194 - // x: y: yaml.Validate(x) 195 - // x: y: "{}" 196 - // } 197 - // selfCycle: yamlVal: t1: { 198 - // x: y: yaml.Validate(x) 199 - // x: y: "{}" 200 - // } 201 - // selfCycle: yamlFun: t1:{ 202 - // x: y?: yaml.Validate("{}", x) 203 - // } 204 - // selfCycle: yamlFun: t2: { 205 - // z: x & __no_sharing 206 - // z: y: "{}" 207 - // x: y: yaml.Validate("{}", x) 208 - // } 193 + selfCycle: yamlVal: t1: { 194 + x: y: yaml.Validate(x) 195 + x: y: "{}" 196 + } 197 + selfCycle: yamlVal: t2: { 198 + // Duplicating validators can cause some tricky code paths, like finalizing 199 + // a node while still in the middle of validation. 200 + x: y: yaml.Validate(x) 201 + x: y: "{}" 202 + x: y: yaml.Validate(x) 203 + x: y: "{}" 204 + } 205 + selfCycle: yamlFun: t1:{ 206 + x: y?: yaml.Validate("{}", x) 207 + } 208 + selfCycle: yamlFun: t2: { 209 + z: x & __no_sharing 210 + z: y: "{}" 211 + x: y: yaml.Validate("{}", x) 212 + } 213 + selfCycle: yamlValidatePartial: { 214 + x: y: yaml.ValidatePartial(x) 215 + x: y: "{}" 216 + } 217 + -- jsoncycle.cue -- 218 + import "encoding/json" 219 + 220 + jsonCycle: t1: { 221 + x: y: json.Validate(x) 222 + x: y: "{}" 223 + } 224 + -- listmatchncycle.cue -- 225 + import "list" 226 + 227 + listMatchN: structCycle: { 228 + x: y: list.MatchN(1, x) 229 + x: y: [{}] 230 + } 231 + listMatchN: ok: { 232 + x: y?: list.MatchN(1, x) 233 + z: x 234 + z: y: [{}] 235 + } 209 236 -- todo/p1 -- 210 237 issue3443.noCycle: fix hang 211 238 -- out/evalalpha/stats -- 212 - Leaks: 351 239 + Leaks: 410 213 240 Freed: 17 214 241 Reused: 17 215 - Allocs: 351 242 + Allocs: 410 216 243 Retain: 0 217 244 218 - Unifications: 310 219 - Conjuncts: 1216 245 + Unifications: 368 246 + Conjuncts: 1497 220 247 Disjuncts: 28 221 248 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- 222 249 diff old new ··· 224 251 +++ new 225 252 @@ -1,9 +1,9 @@ 226 253 -Leaks: 23 227 - -Freed: 357 228 - -Reused: 345 254 + -Freed: 414 255 + -Reused: 402 229 256 -Allocs: 35 230 - -Retain: 94 231 - +Leaks: 351 257 + -Retain: 95 258 + +Leaks: 410 232 259 +Freed: 17 233 260 +Reused: 17 234 - +Allocs: 351 261 + +Allocs: 410 235 262 +Retain: 0 236 263 237 - -Unifications: 352 238 - -Conjuncts: 625 239 - -Disjuncts: 441 240 - +Unifications: 310 241 - +Conjuncts: 1216 264 + -Unifications: 409 265 + -Conjuncts: 764 266 + -Disjuncts: 501 267 + +Unifications: 368 268 + +Conjuncts: 1497 242 269 +Disjuncts: 28 243 270 -- out/eval/stats -- 244 271 Leaks: 23 245 - Freed: 357 246 - Reused: 345 272 + Freed: 414 273 + Reused: 402 247 274 Allocs: 35 248 - Retain: 94 275 + Retain: 95 249 276 250 - Unifications: 352 251 - Conjuncts: 625 252 - Disjuncts: 441 277 + Unifications: 409 278 + Conjuncts: 764 279 + Disjuncts: 501 253 280 -- out/evalalpha -- 254 281 Errors: 255 282 noCycle.t1.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 256 - ./cycle.cue:6:7 257 - ./cycle.cue:6:14 258 - ./cycle.cue:7:13 283 + ./cycle.cue:4:7 284 + ./cycle.cue:4:14 285 + ./cycle.cue:5:13 259 286 noCycle.t1.#x.#x: structural cycle: 260 - ./cycle.cue:6:7 287 + ./cycle.cue:4:7 261 288 noCycle.t1._s.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 262 - ./cycle.cue:6:7 263 - ./cycle.cue:6:14 264 - ./cycle.cue:7:13 289 + ./cycle.cue:4:7 290 + ./cycle.cue:4:14 291 + ./cycle.cue:5:13 265 292 issue3649.cycle.t1.data.a: invalid value {b:"foo"} (does not satisfy matchN): 0 matched, expected 1: 266 - ./cycle.cue:33:6 267 - ./cycle.cue:30:11 268 - ./cycle.cue:33:13 293 + ./cycle.cue:31:6 294 + ./cycle.cue:28:11 295 + ./cycle.cue:31:13 269 296 issue3649.cycle.t1.data.a.a: structural cycle: 270 - ./cycle.cue:33:6 271 - selfCycle.t1.c: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 272 - ./cycle.cue:47:5 273 - ./cycle.cue:47:12 274 - ./cycle.cue:48:5 275 - selfCycle.t1.c.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 276 - ./cycle.cue:47:5 277 - ./cycle.cue:47:12 278 - ./cycle.cue:47:20 279 - ./cycle.cue:48:8 280 - selfCycle.t1.c.d.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 281 - ./cycle.cue:47:5 282 - ./cycle.cue:47:12 283 - ./cycle.cue:47:20 284 - ./cycle.cue:48:8 285 - selfCycle.t1.c.d.d.d: structural cycle: 286 - ./cycle.cue:47:5 297 + ./cycle.cue:31:6 298 + jsonCycle.t1.x.y: invalid value "{}" (does not satisfy encoding/json.Validate): error in call to encoding/json.Validate: structural cycle: 299 + ./jsoncycle.cue:4:8 300 + ./jsoncycle.cue:5:8 301 + listMatchN.structCycle.x.y: invalid value [{}] (does not satisfy list.MatchN): number of matched elements is 0: does not satisfy 1: 302 + ./listmatchncycle.cue:4:8 303 + ./listmatchncycle.cue:4:20 304 + ./listmatchncycle.cue:5:8 287 305 issue3443.matchIf.#S: cannot call non-function matchIf (type struct): 288 306 ./matchn.cue:16:7 289 307 issue3443.cycle1.cycle.s: invalid value {n:{n:_}} (does not satisfy matchN): 0 matched, expected 1: ··· 314 332 ./matchn.cue:55:43 315 333 issue3443.cycle2.fail.#S.n.n.n: structural cycle: 316 334 ./matchn.cue:55:13 335 + selfCycle.t1.c: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 336 + ./yamlcycle.cue:14:5 337 + ./yamlcycle.cue:14:12 338 + ./yamlcycle.cue:15:5 339 + selfCycle.t1.c.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 340 + ./yamlcycle.cue:14:5 341 + ./yamlcycle.cue:14:12 342 + ./yamlcycle.cue:14:20 343 + ./yamlcycle.cue:15:8 344 + selfCycle.t1.c.d.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 345 + ./yamlcycle.cue:14:5 346 + ./yamlcycle.cue:14:12 347 + ./yamlcycle.cue:14:20 348 + ./yamlcycle.cue:15:8 349 + selfCycle.t1.c.d.d.d: structural cycle: 350 + ./yamlcycle.cue:14:5 351 + selfCycle.yamlVal.t1.x.y: invalid value "{}" (does not satisfy encoding/yaml.Validate): error in call to encoding/yaml.Validate: structural cycle: 352 + ./yamlcycle.cue:24:8 353 + ./yamlcycle.cue:25:8 354 + selfCycle.yamlVal.t2.x.y: invalid value "{}" (does not satisfy encoding/yaml.Validate): error in call to encoding/yaml.Validate: structural cycle: 355 + ./yamlcycle.cue:30:8 356 + ./yamlcycle.cue:31:8 357 + ./yamlcycle.cue:32:8 358 + ./yamlcycle.cue:33:8 359 + selfCycle.yamlFun.t2.x.y: error in call to encoding/yaml.Validate: structural cycle: 360 + ./yamlcycle.cue:41:8 361 + selfCycle.yamlFun.t2.z.y: error in call to encoding/yaml.Validate: structural cycle: 362 + ./yamlcycle.cue:41:8 363 + selfCycle.yamlValidatePartial.x.y: invalid value "{}" (does not satisfy encoding/yaml.ValidatePartial): error in call to encoding/yaml.ValidatePartial: structural cycle: 364 + ./yamlcycle.cue:44:8 365 + ./yamlcycle.cue:45:8 317 366 318 367 Result: 319 368 (_|_){ ··· 326 375 // [eval] 327 376 #x: (_|_){ 328 377 // [eval] noCycle.t1._s.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 329 - // ./cycle.cue:6:7 330 - // ./cycle.cue:6:14 331 - // ./cycle.cue:7:13 378 + // ./cycle.cue:4:7 379 + // ./cycle.cue:4:14 380 + // ./cycle.cue:5:13 332 381 } 333 382 } 334 383 #x: (_|_){ 335 384 // [eval] noCycle.t1.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 336 - // ./cycle.cue:6:7 337 - // ./cycle.cue:6:14 338 - // ./cycle.cue:7:13 385 + // ./cycle.cue:4:7 386 + // ./cycle.cue:4:14 387 + // ./cycle.cue:5:13 339 388 // noCycle.t1.#x.#x: structural cycle: 340 - // ./cycle.cue:6:7 389 + // ./cycle.cue:4:7 341 390 } 342 391 } 343 392 } ··· 391 440 // [eval] 392 441 a: (_|_){ 393 442 // [eval] issue3649.cycle.t1.data.a: invalid value {b:"foo"} (does not satisfy matchN): 0 matched, expected 1: 394 - // ./cycle.cue:33:6 395 - // ./cycle.cue:30:11 396 - // ./cycle.cue:33:13 443 + // ./cycle.cue:31:6 444 + // ./cycle.cue:28:11 445 + // ./cycle.cue:31:13 397 446 // issue3649.cycle.t1.data.a.a: structural cycle: 398 - // ./cycle.cue:33:6 447 + // ./cycle.cue:31:6 399 448 b: (string){ "foo" } 400 449 } 401 450 b: (string){ string } ··· 410 459 } 411 460 } 412 461 } 413 - yamlNoCycle: (struct){ 414 - #c: (#struct){ 415 - b?: (string){ string } 416 - a?: ((string|bytes)){ "encoding/yaml".Validate(yamlNoCycle.#c) } 417 - } 418 - data: (#struct){ 419 - a: (string){ "{a: \"b: foo\"}" } 420 - b?: (string){ string } 421 - } 422 - } 423 - selfCycle: (_|_){ 424 - // [eval] 425 - t1: (_|_){ 426 - // [eval] 427 - c: (_|_){ 428 - // [eval] selfCycle.t1.c: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 429 - // ./cycle.cue:47:5 430 - // ./cycle.cue:47:12 431 - // ./cycle.cue:48:5 432 - // selfCycle.t1.c.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 433 - // ./cycle.cue:47:5 434 - // ./cycle.cue:47:12 435 - // ./cycle.cue:47:20 436 - // ./cycle.cue:48:8 437 - // selfCycle.t1.c.d.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 438 - // ./cycle.cue:47:5 439 - // ./cycle.cue:47:12 440 - // ./cycle.cue:47:20 441 - // ./cycle.cue:48:8 442 - // selfCycle.t1.c.d.d.d: structural cycle: 443 - // ./cycle.cue:47:5 444 - d: (struct){ 445 - } 446 - } 447 - } 448 - t2: (struct){ 449 - c: (struct){ 450 - } 451 - } 452 - } 453 462 builtinCyclePerm0: (struct){ 454 463 X: (string){ "mod.test" } 455 464 Y: (struct){ ··· 502 511 host: (string){ "mod.test" } 503 512 } 504 513 host: (string){ "mod.test" } 514 + } 515 + } 516 + jsonCycle: (_|_){ 517 + // [structural cycle] 518 + t1: (_|_){ 519 + // [structural cycle] 520 + x: (_|_){ 521 + // [structural cycle] 522 + y: (_|_){ 523 + // [structural cycle] jsonCycle.t1.x.y: invalid value "{}" (does not satisfy encoding/json.Validate): error in call to encoding/json.Validate: structural cycle: 524 + // ./jsoncycle.cue:4:8 525 + // ./jsoncycle.cue:5:8 526 + } 527 + } 528 + } 529 + } 530 + listMatchN: (_|_){ 531 + // [eval] 532 + structCycle: (_|_){ 533 + // [eval] 534 + x: (_|_){ 535 + // [eval] 536 + y: (_|_){ 537 + // [eval] listMatchN.structCycle.x.y: invalid value [{}] (does not satisfy list.MatchN): number of matched elements is 0: does not satisfy 1: 538 + // ./listmatchncycle.cue:4:8 539 + // ./listmatchncycle.cue:4:20 540 + // ./listmatchncycle.cue:5:8 541 + 0: (struct){ 542 + } 543 + } 544 + } 545 + } 546 + ok: (struct){ 547 + x: (struct){ 548 + y?: (list){ list.MatchN(1, listMatchN.ok.x) } 549 + } 550 + z: (struct){ 551 + y: (#list){ 552 + 0: (struct){ 553 + } 554 + } 555 + } 505 556 } 506 557 } 507 558 issue3410: (struct){ ··· 659 710 }) } 660 711 } 661 712 } 713 + yamlNoCycle: (struct){ 714 + #c: (#struct){ 715 + b?: (string){ string } 716 + a?: ((string|bytes)){ "encoding/yaml".Validate(yamlNoCycle.#c) } 717 + } 718 + data: (#struct){ 719 + a: (string){ "{a: \"b: foo\"}" } 720 + b?: (string){ string } 721 + } 722 + } 723 + selfCycle: (_|_){ 724 + // [eval] 725 + t1: (_|_){ 726 + // [eval] 727 + c: (_|_){ 728 + // [eval] selfCycle.t1.c: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 729 + // ./yamlcycle.cue:14:5 730 + // ./yamlcycle.cue:14:12 731 + // ./yamlcycle.cue:15:5 732 + // selfCycle.t1.c.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 733 + // ./yamlcycle.cue:14:5 734 + // ./yamlcycle.cue:14:12 735 + // ./yamlcycle.cue:14:20 736 + // ./yamlcycle.cue:15:8 737 + // selfCycle.t1.c.d.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 738 + // ./yamlcycle.cue:14:5 739 + // ./yamlcycle.cue:14:12 740 + // ./yamlcycle.cue:14:20 741 + // ./yamlcycle.cue:15:8 742 + // selfCycle.t1.c.d.d.d: structural cycle: 743 + // ./yamlcycle.cue:14:5 744 + d: (struct){ 745 + } 746 + } 747 + } 748 + t2: (struct){ 749 + c: (struct){ 750 + } 751 + } 752 + yamlVal: (_|_){ 753 + // [eval] 754 + t1: (_|_){ 755 + // [eval] 756 + x: (_|_){ 757 + // [eval] 758 + y: (_|_){ 759 + // [eval] selfCycle.yamlVal.t1.x.y: invalid value "{}" (does not satisfy encoding/yaml.Validate): error in call to encoding/yaml.Validate: structural cycle: 760 + // ./yamlcycle.cue:24:8 761 + // ./yamlcycle.cue:25:8 762 + } 763 + } 764 + } 765 + t2: (_|_){ 766 + // [eval] 767 + x: (_|_){ 768 + // [eval] 769 + y: (_|_){ 770 + // [eval] selfCycle.yamlVal.t2.x.y: invalid value "{}" (does not satisfy encoding/yaml.Validate): error in call to encoding/yaml.Validate: structural cycle: 771 + // ./yamlcycle.cue:30:8 772 + // ./yamlcycle.cue:31:8 773 + // ./yamlcycle.cue:32:8 774 + // ./yamlcycle.cue:33:8 775 + } 776 + } 777 + } 778 + } 779 + yamlFun: (_|_){ 780 + // [eval] 781 + t1: (struct){ 782 + x: (struct){ 783 + y?: (bool){ true } 784 + } 785 + } 786 + t2: (_|_){ 787 + // [eval] 788 + z: (_|_){ 789 + // [eval] 790 + y: (_|_){ 791 + // [eval] selfCycle.yamlFun.t2.z.y: error in call to encoding/yaml.Validate: structural cycle: 792 + // ./yamlcycle.cue:41:8 793 + } 794 + } 795 + x: (_|_){ 796 + // [eval] 797 + y: (_|_){ 798 + // [eval] selfCycle.yamlFun.t2.x.y: error in call to encoding/yaml.Validate: structural cycle: 799 + // ./yamlcycle.cue:41:8 800 + } 801 + } 802 + } 803 + } 804 + yamlValidatePartial: (_|_){ 805 + // [structural cycle] 806 + x: (_|_){ 807 + // [structural cycle] 808 + y: (_|_){ 809 + // [structural cycle] selfCycle.yamlValidatePartial.x.y: invalid value "{}" (does not satisfy encoding/yaml.ValidatePartial): error in call to encoding/yaml.ValidatePartial: structural cycle: 810 + // ./yamlcycle.cue:44:8 811 + // ./yamlcycle.cue:45:8 812 + } 813 + } 814 + } 815 + } 662 816 } 663 817 -- diff/-out/evalalpha<==>+out/eval -- 664 818 diff old new 665 819 --- old 666 820 +++ new 667 - @@ -3,18 +3,18 @@ 668 - ./cycle.cue:6:7 669 - ./cycle.cue:6:14 670 - ./cycle.cue:7:13 821 + @@ -3,24 +3,39 @@ 822 + ./cycle.cue:4:7 823 + ./cycle.cue:4:14 824 + ./cycle.cue:5:13 671 825 -noCycle.t1.#x.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 672 - - ./cycle.cue:6:7 673 - - ./cycle.cue:6:14 674 - - ./cycle.cue:7:13 826 + - ./cycle.cue:4:7 827 + - ./cycle.cue:4:14 828 + - ./cycle.cue:5:13 675 829 +noCycle.t1.#x.#x: structural cycle: 676 - + ./cycle.cue:6:7 830 + + ./cycle.cue:4:7 677 831 noCycle.t1._s.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 678 - ./cycle.cue:6:7 679 - ./cycle.cue:6:14 680 - ./cycle.cue:7:13 832 + ./cycle.cue:4:7 833 + ./cycle.cue:4:14 834 + ./cycle.cue:5:13 681 835 -noCycle.t1._s.#x.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 682 - - ./cycle.cue:6:7 683 - - ./cycle.cue:6:14 684 - - ./cycle.cue:7:13 836 + - ./cycle.cue:4:7 837 + - ./cycle.cue:4:14 838 + - ./cycle.cue:5:13 839 + -jsonCycle.t1.x.y.y: structural cycle: 840 + - ./jsoncycle.cue:4:22 841 + -listMatchN.structCycle.x.y.y: structural cycle: 842 + - ./listmatchncycle.cue:4:23 685 843 +issue3649.cycle.t1.data.a: invalid value {b:"foo"} (does not satisfy matchN): 0 matched, expected 1: 686 - + ./cycle.cue:33:6 687 - + ./cycle.cue:30:11 688 - + ./cycle.cue:33:13 844 + + ./cycle.cue:31:6 845 + + ./cycle.cue:28:11 846 + + ./cycle.cue:31:13 689 847 +issue3649.cycle.t1.data.a.a: structural cycle: 690 - + ./cycle.cue:33:6 691 - selfCycle.t1.c: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 692 - ./cycle.cue:47:5 693 - ./cycle.cue:47:12 694 - @@ -31,18 +31,20 @@ 695 - ./cycle.cue:48:8 696 - selfCycle.t1.c.d.d.d: structural cycle: 697 - ./cycle.cue:47:5 698 - -selfCycle.t2.c: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 699 - - ./cycle.cue:53:5 700 - - ./cycle.cue:53:12 701 - - ./cycle.cue:54:5 702 - -selfCycle.t2.c.d: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 703 - - ./cycle.cue:53:5 704 - - ./cycle.cue:53:12 705 - - ./cycle.cue:53:20 706 - -selfCycle.t2.c.d.d: structural cycle: 707 - - ./cycle.cue:53:5 848 + + ./cycle.cue:31:6 849 + +jsonCycle.t1.x.y: invalid value "{}" (does not satisfy encoding/json.Validate): error in call to encoding/json.Validate: structural cycle: 850 + + ./jsoncycle.cue:4:8 851 + + ./jsoncycle.cue:5:8 852 + +listMatchN.structCycle.x.y: invalid value [{}] (does not satisfy list.MatchN): number of matched elements is 0: does not satisfy 1: 853 + + ./listmatchncycle.cue:4:8 854 + + ./listmatchncycle.cue:4:20 855 + + ./listmatchncycle.cue:5:8 708 856 issue3443.matchIf.#S: cannot call non-function matchIf (type struct): 709 857 ./matchn.cue:16:7 710 858 +issue3443.cycle1.cycle.s: invalid value {n:{n:_}} (does not satisfy matchN): 0 matched, expected 1: ··· 722 870 issue3443.cycle2.fail.#S: invalid value {n:{n:{n:_}}} (does not satisfy matchN): 0 matched, expected 1: 723 871 ./matchn.cue:55:13 724 872 ./matchn.cue:55:20 725 - @@ -74,10 +76,6 @@ 726 - // ./cycle.cue:6:7 727 - // ./cycle.cue:6:14 728 - // ./cycle.cue:7:13 873 + @@ -53,26 +68,21 @@ 874 + ./yamlcycle.cue:15:8 875 + selfCycle.t1.c.d.d.d: structural cycle: 876 + ./yamlcycle.cue:14:5 877 + -selfCycle.t2.c: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 878 + - ./yamlcycle.cue:20:5 879 + - ./yamlcycle.cue:20:12 880 + - ./yamlcycle.cue:21:5 881 + -selfCycle.t2.c.d: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 882 + - ./yamlcycle.cue:20:5 883 + - ./yamlcycle.cue:20:12 884 + - ./yamlcycle.cue:20:20 885 + -selfCycle.t2.c.d.d: structural cycle: 886 + - ./yamlcycle.cue:20:5 887 + -selfCycle.yamlVal.t1.x.y.y: structural cycle: 888 + - ./yamlcycle.cue:24:22 889 + -selfCycle.yamlVal.t2.x.y.y: structural cycle: 890 + - ./yamlcycle.cue:32:22 891 + -selfCycle.yamlFun.t1.x.y.y: structural cycle: 892 + - ./yamlcycle.cue:36:29 893 + -selfCycle.yamlFun.t2.x.y.y: structural cycle: 894 + - ./yamlcycle.cue:41:28 895 + -selfCycle.yamlValidatePartial.x.y.y: structural cycle: 896 + - ./yamlcycle.cue:44:29 897 + +selfCycle.yamlVal.t1.x.y: invalid value "{}" (does not satisfy encoding/yaml.Validate): error in call to encoding/yaml.Validate: structural cycle: 898 + + ./yamlcycle.cue:24:8 899 + + ./yamlcycle.cue:25:8 900 + +selfCycle.yamlVal.t2.x.y: invalid value "{}" (does not satisfy encoding/yaml.Validate): error in call to encoding/yaml.Validate: structural cycle: 901 + + ./yamlcycle.cue:30:8 902 + + ./yamlcycle.cue:31:8 903 + + ./yamlcycle.cue:32:8 904 + + ./yamlcycle.cue:33:8 905 + +selfCycle.yamlFun.t2.x.y: error in call to encoding/yaml.Validate: structural cycle: 906 + + ./yamlcycle.cue:41:8 907 + +selfCycle.yamlFun.t2.z.y: error in call to encoding/yaml.Validate: structural cycle: 908 + + ./yamlcycle.cue:41:8 909 + +selfCycle.yamlValidatePartial.x.y: invalid value "{}" (does not satisfy encoding/yaml.ValidatePartial): error in call to encoding/yaml.ValidatePartial: structural cycle: 910 + + ./yamlcycle.cue:44:8 911 + + ./yamlcycle.cue:45:8 912 + 913 + Result: 914 + (_|_){ 915 + @@ -88,10 +98,6 @@ 916 + // ./cycle.cue:4:7 917 + // ./cycle.cue:4:14 918 + // ./cycle.cue:5:13 729 919 - // noCycle.t1._s.#x.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 730 - - // ./cycle.cue:6:7 731 - - // ./cycle.cue:6:14 732 - - // ./cycle.cue:7:13 920 + - // ./cycle.cue:4:7 921 + - // ./cycle.cue:4:14 922 + - // ./cycle.cue:5:13 733 923 } 734 924 } 735 925 #x: (_|_){ 736 - @@ -85,26 +83,25 @@ 737 - // ./cycle.cue:6:7 738 - // ./cycle.cue:6:14 739 - // ./cycle.cue:7:13 926 + @@ -99,26 +105,25 @@ 927 + // ./cycle.cue:4:7 928 + // ./cycle.cue:4:14 929 + // ./cycle.cue:5:13 740 930 - // noCycle.t1.#x.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 741 - - // ./cycle.cue:6:7 742 - - // ./cycle.cue:6:14 743 - - // ./cycle.cue:7:13 931 + - // ./cycle.cue:4:7 932 + - // ./cycle.cue:4:14 933 + - // ./cycle.cue:5:13 744 934 - } 745 935 - } 746 936 - } ··· 753 943 - b: (string){ "foo" } 754 944 - } 755 945 + // noCycle.t1.#x.#x: structural cycle: 756 - + // ./cycle.cue:6:7 946 + + // ./cycle.cue:4:7 757 947 + } 758 948 + } 759 949 + } ··· 775 965 } 776 966 }) } 777 967 } 778 - @@ -111,7 +108,6 @@ 968 + @@ -125,7 +130,6 @@ 779 969 } 780 970 t2: (struct){ 781 971 x: (struct){ ··· 783 973 y: (struct){ 784 974 a: (struct){ 785 975 d: (struct){ 786 - @@ -119,14 +115,15 @@ 976 + @@ -133,14 +137,15 @@ 787 977 } 788 978 } 789 979 } ··· 801 991 } 802 992 }) } 803 993 } 804 - @@ -133,18 +130,27 @@ 994 + @@ -147,18 +152,27 @@ 805 995 } 806 996 } 807 997 } ··· 820 1010 + // [eval] 821 1011 + a: (_|_){ 822 1012 + // [eval] issue3649.cycle.t1.data.a: invalid value {b:"foo"} (does not satisfy matchN): 0 matched, expected 1: 823 - + // ./cycle.cue:33:6 824 - + // ./cycle.cue:30:11 825 - + // ./cycle.cue:33:13 1013 + + // ./cycle.cue:31:6 1014 + + // ./cycle.cue:28:11 1015 + + // ./cycle.cue:31:13 826 1016 + // issue3649.cycle.t1.data.a.a: structural cycle: 827 - + // ./cycle.cue:33:6 1017 + + // ./cycle.cue:31:6 828 1018 + b: (string){ "foo" } 829 1019 + } 830 1020 + b: (string){ string } ··· 837 1027 } 838 1028 }) } 839 1029 } 840 - @@ -157,8 +163,8 @@ 841 - a?: ((string|bytes)){ "encoding/yaml".Validate(yamlNoCycle.#c) } 842 - } 843 - data: (#struct){ 844 - - b?: (string){ string } 845 - a: (string){ "{a: \"b: foo\"}" } 846 - + b?: (string){ string } 847 - } 848 - } 849 - selfCycle: (_|_){ 850 - @@ -186,19 +192,8 @@ 851 - } 1030 + @@ -224,8 +238,12 @@ 1031 + t1: (_|_){ 1032 + // [structural cycle] 1033 + x: (_|_){ 1034 + - // [structural cycle] jsonCycle.t1.x.y.y: structural cycle: 1035 + - // ./jsoncycle.cue:4:22 1036 + + // [structural cycle] 1037 + + y: (_|_){ 1038 + + // [structural cycle] jsonCycle.t1.x.y: invalid value "{}" (does not satisfy encoding/json.Validate): error in call to encoding/json.Validate: structural cycle: 1039 + + // ./jsoncycle.cue:4:8 1040 + + // ./jsoncycle.cue:5:8 1041 + + } 852 1042 } 853 1043 } 854 - - t2: (_|_){ 855 - - // [eval] 856 - - c: (_|_){ 857 - - // [eval] selfCycle.t2.c: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 858 - - // ./cycle.cue:53:5 859 - - // ./cycle.cue:53:12 860 - - // ./cycle.cue:54:5 861 - - // selfCycle.t2.c.d: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 862 - - // ./cycle.cue:53:5 863 - - // ./cycle.cue:53:12 864 - - // ./cycle.cue:53:20 865 - - // selfCycle.t2.c.d.d: structural cycle: 866 - - // ./cycle.cue:53:5 867 - + t2: (struct){ 868 - + c: (struct){ 1044 + } 1045 + @@ -234,8 +252,15 @@ 1046 + structCycle: (_|_){ 1047 + // [eval] 1048 + x: (_|_){ 1049 + - // [eval] listMatchN.structCycle.x.y.y: structural cycle: 1050 + - // ./listmatchncycle.cue:4:23 1051 + + // [eval] 1052 + + y: (_|_){ 1053 + + // [eval] listMatchN.structCycle.x.y: invalid value [{}] (does not satisfy list.MatchN): number of matched elements is 0: does not satisfy 1: 1054 + + // ./listmatchncycle.cue:4:8 1055 + + // ./listmatchncycle.cue:4:20 1056 + + // ./listmatchncycle.cue:5:8 1057 + + 0: (struct){ 1058 + + } 1059 + + } 869 1060 } 870 1061 } 871 - } 872 - @@ -259,20 +254,20 @@ 1062 + ok: (struct){ 1063 + @@ -253,20 +278,20 @@ 873 1064 issue3410: (struct){ 874 1065 _s: (struct){ 875 1066 #x: (_){ matchN(1, (#list){ ··· 898 1089 } 899 1090 }) } 900 1091 } 901 - @@ -279,9 +274,9 @@ 1092 + @@ -273,9 +298,9 @@ 902 1093 issue3420: (struct){ 903 1094 matches1: (struct){ 904 1095 #S: (_){ matchN(1, (#list){ ··· 911 1102 } 912 1103 }) } 913 1104 s: (int){ 2 } 914 - @@ -298,13 +293,13 @@ 1105 + @@ -292,13 +317,13 @@ 915 1106 } 916 1107 noCycle: (struct){ 917 1108 #S: (_){ matchN(1, (#list){ ··· 928 1119 n: (struct){ 929 1120 n: (_){ _ } 930 1121 } 931 - @@ -313,29 +308,43 @@ 1122 + @@ -307,29 +332,43 @@ 932 1123 } 933 1124 noCycle2: (struct){ 934 1125 #S: (_){ matchN(1, (#list){ ··· 985 1176 n: (struct){ 986 1177 n: (_){ _ } 987 1178 } 988 - @@ -388,11 +397,11 @@ 1179 + @@ -382,11 +421,11 @@ 989 1180 // ./matchn.cue:63:24 990 1181 } 991 1182 #s: (_){ matchN(1, (#list){ ··· 999 1190 } 1000 1191 }) } 1001 1192 } 1193 + @@ -397,8 +436,8 @@ 1194 + a?: ((string|bytes)){ "encoding/yaml".Validate(yamlNoCycle.#c) } 1195 + } 1196 + data: (#struct){ 1197 + - b?: (string){ string } 1198 + a: (string){ "{a: \"b: foo\"}" } 1199 + + b?: (string){ string } 1200 + } 1201 + } 1202 + selfCycle: (_|_){ 1203 + @@ -426,19 +465,8 @@ 1204 + } 1205 + } 1206 + } 1207 + - t2: (_|_){ 1208 + - // [eval] 1209 + - c: (_|_){ 1210 + - // [eval] selfCycle.t2.c: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1211 + - // ./yamlcycle.cue:20:5 1212 + - // ./yamlcycle.cue:20:12 1213 + - // ./yamlcycle.cue:21:5 1214 + - // selfCycle.t2.c.d: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1215 + - // ./yamlcycle.cue:20:5 1216 + - // ./yamlcycle.cue:20:12 1217 + - // ./yamlcycle.cue:20:20 1218 + - // selfCycle.t2.c.d.d: structural cycle: 1219 + - // ./yamlcycle.cue:20:5 1220 + + t2: (struct){ 1221 + + c: (struct){ 1222 + } 1223 + } 1224 + yamlVal: (_|_){ 1225 + @@ -446,25 +474,33 @@ 1226 + t1: (_|_){ 1227 + // [eval] 1228 + x: (_|_){ 1229 + - // [eval] selfCycle.yamlVal.t1.x.y.y: structural cycle: 1230 + - // ./yamlcycle.cue:24:22 1231 + - } 1232 + - } 1233 + - t2: (_|_){ 1234 + - // [eval] 1235 + - x: (_|_){ 1236 + - // [eval] selfCycle.yamlVal.t2.x.y.y: structural cycle: 1237 + - // ./yamlcycle.cue:32:22 1238 + + // [eval] 1239 + + y: (_|_){ 1240 + + // [eval] selfCycle.yamlVal.t1.x.y: invalid value "{}" (does not satisfy encoding/yaml.Validate): error in call to encoding/yaml.Validate: structural cycle: 1241 + + // ./yamlcycle.cue:24:8 1242 + + // ./yamlcycle.cue:25:8 1243 + + } 1244 + + } 1245 + + } 1246 + + t2: (_|_){ 1247 + + // [eval] 1248 + + x: (_|_){ 1249 + + // [eval] 1250 + + y: (_|_){ 1251 + + // [eval] selfCycle.yamlVal.t2.x.y: invalid value "{}" (does not satisfy encoding/yaml.Validate): error in call to encoding/yaml.Validate: structural cycle: 1252 + + // ./yamlcycle.cue:30:8 1253 + + // ./yamlcycle.cue:31:8 1254 + + // ./yamlcycle.cue:32:8 1255 + + // ./yamlcycle.cue:33:8 1256 + + } 1257 + } 1258 + } 1259 + } 1260 + yamlFun: (_|_){ 1261 + // [eval] 1262 + - t1: (_|_){ 1263 + - // [structural cycle] 1264 + - x: (_|_){ 1265 + - // [structural cycle] selfCycle.yamlFun.t1.x.y.y: structural cycle: 1266 + - // ./yamlcycle.cue:36:29 1267 + + t1: (struct){ 1268 + + x: (struct){ 1269 + + y?: (bool){ true } 1270 + } 1271 + } 1272 + t2: (_|_){ 1273 + @@ -472,13 +508,16 @@ 1274 + z: (_|_){ 1275 + // [eval] 1276 + y: (_|_){ 1277 + - // [eval] selfCycle.yamlFun.t2.x.y.y: structural cycle: 1278 + - // ./yamlcycle.cue:41:28 1279 + - } 1280 + - } 1281 + - x: (_|_){ 1282 + - // [eval] selfCycle.yamlFun.t2.x.y.y: structural cycle: 1283 + - // ./yamlcycle.cue:41:28 1284 + + // [eval] selfCycle.yamlFun.t2.z.y: error in call to encoding/yaml.Validate: structural cycle: 1285 + + // ./yamlcycle.cue:41:8 1286 + + } 1287 + + } 1288 + + x: (_|_){ 1289 + + // [eval] 1290 + + y: (_|_){ 1291 + + // [eval] selfCycle.yamlFun.t2.x.y: error in call to encoding/yaml.Validate: structural cycle: 1292 + + // ./yamlcycle.cue:41:8 1293 + + } 1294 + } 1295 + } 1296 + } 1297 + @@ -485,8 +524,12 @@ 1298 + yamlValidatePartial: (_|_){ 1299 + // [structural cycle] 1300 + x: (_|_){ 1301 + - // [structural cycle] selfCycle.yamlValidatePartial.x.y.y: structural cycle: 1302 + - // ./yamlcycle.cue:44:29 1303 + + // [structural cycle] 1304 + + y: (_|_){ 1305 + + // [structural cycle] selfCycle.yamlValidatePartial.x.y: invalid value "{}" (does not satisfy encoding/yaml.ValidatePartial): error in call to encoding/yaml.ValidatePartial: structural cycle: 1306 + + // ./yamlcycle.cue:44:8 1307 + + // ./yamlcycle.cue:45:8 1308 + + } 1309 + } 1310 + } 1311 + } 1002 1312 -- diff/todo/p2 -- 1003 1313 issue3443: Sort out differences in reporting of cycles. 1004 1314 -- out/eval -- 1005 1315 Errors: 1006 1316 noCycle.t1.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1007 - ./cycle.cue:6:7 1008 - ./cycle.cue:6:14 1009 - ./cycle.cue:7:13 1317 + ./cycle.cue:4:7 1318 + ./cycle.cue:4:14 1319 + ./cycle.cue:5:13 1010 1320 noCycle.t1.#x.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1011 - ./cycle.cue:6:7 1012 - ./cycle.cue:6:14 1013 - ./cycle.cue:7:13 1321 + ./cycle.cue:4:7 1322 + ./cycle.cue:4:14 1323 + ./cycle.cue:5:13 1014 1324 noCycle.t1._s.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1015 - ./cycle.cue:6:7 1016 - ./cycle.cue:6:14 1017 - ./cycle.cue:7:13 1325 + ./cycle.cue:4:7 1326 + ./cycle.cue:4:14 1327 + ./cycle.cue:5:13 1018 1328 noCycle.t1._s.#x.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1019 - ./cycle.cue:6:7 1020 - ./cycle.cue:6:14 1021 - ./cycle.cue:7:13 1022 - selfCycle.t1.c: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1023 - ./cycle.cue:47:5 1024 - ./cycle.cue:47:12 1025 - ./cycle.cue:48:5 1026 - selfCycle.t1.c.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1027 - ./cycle.cue:47:5 1028 - ./cycle.cue:47:12 1029 - ./cycle.cue:47:20 1030 - ./cycle.cue:48:8 1031 - selfCycle.t1.c.d.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1032 - ./cycle.cue:47:5 1033 - ./cycle.cue:47:12 1034 - ./cycle.cue:47:20 1035 - ./cycle.cue:48:8 1036 - selfCycle.t1.c.d.d.d: structural cycle: 1037 - ./cycle.cue:47:5 1038 - selfCycle.t2.c: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1039 - ./cycle.cue:53:5 1040 - ./cycle.cue:53:12 1041 - ./cycle.cue:54:5 1042 - selfCycle.t2.c.d: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1043 - ./cycle.cue:53:5 1044 - ./cycle.cue:53:12 1045 - ./cycle.cue:53:20 1046 - selfCycle.t2.c.d.d: structural cycle: 1047 - ./cycle.cue:53:5 1329 + ./cycle.cue:4:7 1330 + ./cycle.cue:4:14 1331 + ./cycle.cue:5:13 1332 + jsonCycle.t1.x.y.y: structural cycle: 1333 + ./jsoncycle.cue:4:22 1334 + listMatchN.structCycle.x.y.y: structural cycle: 1335 + ./listmatchncycle.cue:4:23 1048 1336 issue3443.matchIf.#S: cannot call non-function matchIf (type struct): 1049 1337 ./matchn.cue:16:7 1050 1338 issue3443.cycle2.fail.#S: invalid value {n:{n:{n:_}}} (does not satisfy matchN): 0 matched, expected 1: ··· 1063 1351 ./matchn.cue:55:43 1064 1352 issue3443.cycle2.fail.#S.n.n.n: structural cycle: 1065 1353 ./matchn.cue:55:13 1354 + selfCycle.t1.c: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1355 + ./yamlcycle.cue:14:5 1356 + ./yamlcycle.cue:14:12 1357 + ./yamlcycle.cue:15:5 1358 + selfCycle.t1.c.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1359 + ./yamlcycle.cue:14:5 1360 + ./yamlcycle.cue:14:12 1361 + ./yamlcycle.cue:14:20 1362 + ./yamlcycle.cue:15:8 1363 + selfCycle.t1.c.d.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1364 + ./yamlcycle.cue:14:5 1365 + ./yamlcycle.cue:14:12 1366 + ./yamlcycle.cue:14:20 1367 + ./yamlcycle.cue:15:8 1368 + selfCycle.t1.c.d.d.d: structural cycle: 1369 + ./yamlcycle.cue:14:5 1370 + selfCycle.t2.c: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1371 + ./yamlcycle.cue:20:5 1372 + ./yamlcycle.cue:20:12 1373 + ./yamlcycle.cue:21:5 1374 + selfCycle.t2.c.d: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1375 + ./yamlcycle.cue:20:5 1376 + ./yamlcycle.cue:20:12 1377 + ./yamlcycle.cue:20:20 1378 + selfCycle.t2.c.d.d: structural cycle: 1379 + ./yamlcycle.cue:20:5 1380 + selfCycle.yamlVal.t1.x.y.y: structural cycle: 1381 + ./yamlcycle.cue:24:22 1382 + selfCycle.yamlVal.t2.x.y.y: structural cycle: 1383 + ./yamlcycle.cue:32:22 1384 + selfCycle.yamlFun.t1.x.y.y: structural cycle: 1385 + ./yamlcycle.cue:36:29 1386 + selfCycle.yamlFun.t2.x.y.y: structural cycle: 1387 + ./yamlcycle.cue:41:28 1388 + selfCycle.yamlValidatePartial.x.y.y: structural cycle: 1389 + ./yamlcycle.cue:44:29 1066 1390 1067 1391 Result: 1068 1392 (_|_){ ··· 1075 1399 // [eval] 1076 1400 #x: (_|_){ 1077 1401 // [eval] noCycle.t1._s.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1078 - // ./cycle.cue:6:7 1079 - // ./cycle.cue:6:14 1080 - // ./cycle.cue:7:13 1402 + // ./cycle.cue:4:7 1403 + // ./cycle.cue:4:14 1404 + // ./cycle.cue:5:13 1081 1405 // noCycle.t1._s.#x.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1082 - // ./cycle.cue:6:7 1083 - // ./cycle.cue:6:14 1084 - // ./cycle.cue:7:13 1406 + // ./cycle.cue:4:7 1407 + // ./cycle.cue:4:14 1408 + // ./cycle.cue:5:13 1085 1409 } 1086 1410 } 1087 1411 #x: (_|_){ 1088 1412 // [eval] noCycle.t1.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1089 - // ./cycle.cue:6:7 1090 - // ./cycle.cue:6:14 1091 - // ./cycle.cue:7:13 1413 + // ./cycle.cue:4:7 1414 + // ./cycle.cue:4:14 1415 + // ./cycle.cue:5:13 1092 1416 // noCycle.t1.#x.#x: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1093 - // ./cycle.cue:6:7 1094 - // ./cycle.cue:6:14 1095 - // ./cycle.cue:7:13 1417 + // ./cycle.cue:4:7 1418 + // ./cycle.cue:4:14 1419 + // ./cycle.cue:5:13 1096 1420 } 1097 1421 } 1098 1422 } ··· 1155 1479 } 1156 1480 } 1157 1481 } 1158 - yamlNoCycle: (struct){ 1159 - #c: (#struct){ 1160 - b?: (string){ string } 1161 - a?: ((string|bytes)){ "encoding/yaml".Validate(yamlNoCycle.#c) } 1162 - } 1163 - data: (#struct){ 1164 - b?: (string){ string } 1165 - a: (string){ "{a: \"b: foo\"}" } 1166 - } 1167 - } 1168 - selfCycle: (_|_){ 1169 - // [eval] 1170 - t1: (_|_){ 1171 - // [eval] 1172 - c: (_|_){ 1173 - // [eval] selfCycle.t1.c: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1174 - // ./cycle.cue:47:5 1175 - // ./cycle.cue:47:12 1176 - // ./cycle.cue:48:5 1177 - // selfCycle.t1.c.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1178 - // ./cycle.cue:47:5 1179 - // ./cycle.cue:47:12 1180 - // ./cycle.cue:47:20 1181 - // ./cycle.cue:48:8 1182 - // selfCycle.t1.c.d.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1183 - // ./cycle.cue:47:5 1184 - // ./cycle.cue:47:12 1185 - // ./cycle.cue:47:20 1186 - // ./cycle.cue:48:8 1187 - // selfCycle.t1.c.d.d.d: structural cycle: 1188 - // ./cycle.cue:47:5 1189 - d: (struct){ 1190 - } 1191 - } 1192 - } 1193 - t2: (_|_){ 1194 - // [eval] 1195 - c: (_|_){ 1196 - // [eval] selfCycle.t2.c: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1197 - // ./cycle.cue:53:5 1198 - // ./cycle.cue:53:12 1199 - // ./cycle.cue:54:5 1200 - // selfCycle.t2.c.d: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1201 - // ./cycle.cue:53:5 1202 - // ./cycle.cue:53:12 1203 - // ./cycle.cue:53:20 1204 - // selfCycle.t2.c.d.d: structural cycle: 1205 - // ./cycle.cue:53:5 1206 - } 1207 - } 1208 - } 1209 1482 builtinCyclePerm0: (struct){ 1210 1483 X: (string){ "mod.test" } 1211 1484 Y: (struct){ ··· 1260 1533 host: (string){ "mod.test" } 1261 1534 } 1262 1535 } 1536 + jsonCycle: (_|_){ 1537 + // [structural cycle] 1538 + t1: (_|_){ 1539 + // [structural cycle] 1540 + x: (_|_){ 1541 + // [structural cycle] jsonCycle.t1.x.y.y: structural cycle: 1542 + // ./jsoncycle.cue:4:22 1543 + } 1544 + } 1545 + } 1546 + listMatchN: (_|_){ 1547 + // [eval] 1548 + structCycle: (_|_){ 1549 + // [eval] 1550 + x: (_|_){ 1551 + // [eval] listMatchN.structCycle.x.y.y: structural cycle: 1552 + // ./listmatchncycle.cue:4:23 1553 + } 1554 + } 1555 + ok: (struct){ 1556 + x: (struct){ 1557 + y?: (list){ list.MatchN(1, listMatchN.ok.x) } 1558 + } 1559 + z: (struct){ 1560 + y: (#list){ 1561 + 0: (struct){ 1562 + } 1563 + } 1564 + } 1565 + } 1566 + } 1263 1567 issue3410: (struct){ 1264 1568 _s: (struct){ 1265 1569 #x: (_){ matchN(1, (#list){ ··· 1401 1705 }) } 1402 1706 } 1403 1707 } 1708 + yamlNoCycle: (struct){ 1709 + #c: (#struct){ 1710 + b?: (string){ string } 1711 + a?: ((string|bytes)){ "encoding/yaml".Validate(yamlNoCycle.#c) } 1712 + } 1713 + data: (#struct){ 1714 + b?: (string){ string } 1715 + a: (string){ "{a: \"b: foo\"}" } 1716 + } 1717 + } 1718 + selfCycle: (_|_){ 1719 + // [eval] 1720 + t1: (_|_){ 1721 + // [eval] 1722 + c: (_|_){ 1723 + // [eval] selfCycle.t1.c: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1724 + // ./yamlcycle.cue:14:5 1725 + // ./yamlcycle.cue:14:12 1726 + // ./yamlcycle.cue:15:5 1727 + // selfCycle.t1.c.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1728 + // ./yamlcycle.cue:14:5 1729 + // ./yamlcycle.cue:14:12 1730 + // ./yamlcycle.cue:14:20 1731 + // ./yamlcycle.cue:15:8 1732 + // selfCycle.t1.c.d.d: invalid value {d:{}} (does not satisfy matchN): 0 matched, expected 1: 1733 + // ./yamlcycle.cue:14:5 1734 + // ./yamlcycle.cue:14:12 1735 + // ./yamlcycle.cue:14:20 1736 + // ./yamlcycle.cue:15:8 1737 + // selfCycle.t1.c.d.d.d: structural cycle: 1738 + // ./yamlcycle.cue:14:5 1739 + d: (struct){ 1740 + } 1741 + } 1742 + } 1743 + t2: (_|_){ 1744 + // [eval] 1745 + c: (_|_){ 1746 + // [eval] selfCycle.t2.c: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1747 + // ./yamlcycle.cue:20:5 1748 + // ./yamlcycle.cue:20:12 1749 + // ./yamlcycle.cue:21:5 1750 + // selfCycle.t2.c.d: invalid value {} (does not satisfy matchN): 0 matched, expected 1: 1751 + // ./yamlcycle.cue:20:5 1752 + // ./yamlcycle.cue:20:12 1753 + // ./yamlcycle.cue:20:20 1754 + // selfCycle.t2.c.d.d: structural cycle: 1755 + // ./yamlcycle.cue:20:5 1756 + } 1757 + } 1758 + yamlVal: (_|_){ 1759 + // [eval] 1760 + t1: (_|_){ 1761 + // [eval] 1762 + x: (_|_){ 1763 + // [eval] selfCycle.yamlVal.t1.x.y.y: structural cycle: 1764 + // ./yamlcycle.cue:24:22 1765 + } 1766 + } 1767 + t2: (_|_){ 1768 + // [eval] 1769 + x: (_|_){ 1770 + // [eval] selfCycle.yamlVal.t2.x.y.y: structural cycle: 1771 + // ./yamlcycle.cue:32:22 1772 + } 1773 + } 1774 + } 1775 + yamlFun: (_|_){ 1776 + // [eval] 1777 + t1: (_|_){ 1778 + // [structural cycle] 1779 + x: (_|_){ 1780 + // [structural cycle] selfCycle.yamlFun.t1.x.y.y: structural cycle: 1781 + // ./yamlcycle.cue:36:29 1782 + } 1783 + } 1784 + t2: (_|_){ 1785 + // [eval] 1786 + z: (_|_){ 1787 + // [eval] 1788 + y: (_|_){ 1789 + // [eval] selfCycle.yamlFun.t2.x.y.y: structural cycle: 1790 + // ./yamlcycle.cue:41:28 1791 + } 1792 + } 1793 + x: (_|_){ 1794 + // [eval] selfCycle.yamlFun.t2.x.y.y: structural cycle: 1795 + // ./yamlcycle.cue:41:28 1796 + } 1797 + } 1798 + } 1799 + yamlValidatePartial: (_|_){ 1800 + // [structural cycle] 1801 + x: (_|_){ 1802 + // [structural cycle] selfCycle.yamlValidatePartial.x.y.y: structural cycle: 1803 + // ./yamlcycle.cue:44:29 1804 + } 1805 + } 1806 + } 1404 1807 } 1405 1808 -- out/compile -- 1406 1809 --- cycle.cue ··· 1478 1881 } 1479 1882 } 1480 1883 } 1481 - yamlNoCycle: { 1482 - #c: { 1483 - b?: string 1484 - a?: 〈import;"encoding/yaml"〉.Validate(〈1;#c〉) 1485 - } 1486 - data: 〈0;#c〉 1487 - data: { 1488 - a: "{a: \"b: foo\"}" 1489 - } 1490 - } 1491 - selfCycle: { 1492 - t1: { 1493 - c: matchN(1, [ 1494 - { 1495 - d: 〈2;c〉 1496 - }, 1497 - ]) 1498 - c: { 1499 - d: {} 1500 - } 1501 - } 1502 - } 1503 - selfCycle: { 1504 - t2: { 1505 - c: matchN(1, [ 1506 - { 1507 - d: 〈2;c〉 1508 - }, 1509 - ]) 1510 - c: {} 1511 - } 1512 - } 1513 1884 } 1514 1885 --- in.cue 1515 1886 { ··· 1562 1933 } 1563 1934 } 1564 1935 } 1936 + --- jsoncycle.cue 1937 + { 1938 + jsonCycle: { 1939 + t1: { 1940 + x: { 1941 + y: 〈import;"encoding/json"〉.Validate(〈1;x〉) 1942 + } 1943 + x: { 1944 + y: "{}" 1945 + } 1946 + } 1947 + } 1948 + } 1949 + --- listmatchncycle.cue 1950 + { 1951 + listMatchN: { 1952 + structCycle: { 1953 + x: { 1954 + y: 〈import;list〉.MatchN(1, 〈1;x〉) 1955 + } 1956 + x: { 1957 + y: [ 1958 + {}, 1959 + ] 1960 + } 1961 + } 1962 + } 1963 + listMatchN: { 1964 + ok: { 1965 + x: { 1966 + y?: 〈import;list〉.MatchN(1, 〈1;x〉) 1967 + } 1968 + z: 〈0;x〉 1969 + z: { 1970 + y: [ 1971 + {}, 1972 + ] 1973 + } 1974 + } 1975 + } 1976 + } 1565 1977 --- matchn.cue 1566 1978 { 1567 1979 issue3410: { ··· 1662 2074 } 1663 2075 } 1664 2076 } 2077 + --- yamlcycle.cue 2078 + { 2079 + yamlNoCycle: { 2080 + #c: { 2081 + b?: string 2082 + a?: 〈import;"encoding/yaml"〉.Validate(〈1;#c〉) 2083 + } 2084 + data: 〈0;#c〉 2085 + data: { 2086 + a: "{a: \"b: foo\"}" 2087 + } 2088 + } 2089 + selfCycle: { 2090 + t1: { 2091 + c: matchN(1, [ 2092 + { 2093 + d: 〈2;c〉 2094 + }, 2095 + ]) 2096 + c: { 2097 + d: {} 2098 + } 2099 + } 2100 + } 2101 + selfCycle: { 2102 + t2: { 2103 + c: matchN(1, [ 2104 + { 2105 + d: 〈2;c〉 2106 + }, 2107 + ]) 2108 + c: {} 2109 + } 2110 + } 2111 + selfCycle: { 2112 + yamlVal: { 2113 + t1: { 2114 + x: { 2115 + y: 〈import;"encoding/yaml"〉.Validate(〈1;x〉) 2116 + } 2117 + x: { 2118 + y: "{}" 2119 + } 2120 + } 2121 + } 2122 + } 2123 + selfCycle: { 2124 + yamlVal: { 2125 + t2: { 2126 + x: { 2127 + y: 〈import;"encoding/yaml"〉.Validate(〈1;x〉) 2128 + } 2129 + x: { 2130 + y: "{}" 2131 + } 2132 + x: { 2133 + y: 〈import;"encoding/yaml"〉.Validate(〈1;x〉) 2134 + } 2135 + x: { 2136 + y: "{}" 2137 + } 2138 + } 2139 + } 2140 + } 2141 + selfCycle: { 2142 + yamlFun: { 2143 + t1: { 2144 + x: { 2145 + y?: 〈import;"encoding/yaml"〉.Validate("{}", 〈1;x〉) 2146 + } 2147 + } 2148 + } 2149 + } 2150 + selfCycle: { 2151 + yamlFun: { 2152 + t2: { 2153 + z: (〈0;x〉 & _|_(no sharing)) 2154 + z: { 2155 + y: "{}" 2156 + } 2157 + x: { 2158 + y: 〈import;"encoding/yaml"〉.Validate("{}", 〈1;x〉) 2159 + } 2160 + } 2161 + } 2162 + } 2163 + selfCycle: { 2164 + yamlValidatePartial: { 2165 + x: { 2166 + y: 〈import;"encoding/yaml"〉.ValidatePartial(〈1;x〉) 2167 + } 2168 + x: { 2169 + y: "{}" 2170 + } 2171 + } 2172 + } 2173 + }
+1
internal/core/adt/eval_test.go
··· 76 76 // counter errors. 77 77 // TODO: These counters should all go to zero. 78 78 var skipDebugDepErrors = map[string]int{ 79 + "cycle/builtins": 3, 79 80 "disjunctions/elimination": 4, 80 81 "eval/notify": 3, 81 82 }
+6 -1
internal/pkg/context.go
··· 51 51 } 52 52 53 53 // Schema returns the ith argument as is, without converting it to a cue.Value. 54 + // 55 + // TODO: Schema should use CallContext.Expr to capture cycle information. 56 + // However, this only makes sense if functions also use the same OpContext for 57 + // further evaluation. We should enforce as we port the old calls. 54 58 func (c *CallCtxt) Schema(i int) Schema { 55 - return value.Make(c.ctx, c.args[i]) 59 + v := c.Expr(i) 60 + return value.Make(c.ctx, v) 56 61 } 57 62 58 63 // Value returns a finalized cue.Value for the ith argument.
+5
pkg/encoding/json/manual.go
··· 134 134 // specified by v. 135 135 func Validate(b []byte, v pkg.Schema) (bool, error) { 136 136 c := value.OpContext(v) 137 + return validate(c, b, v) 138 + } 139 + 140 + // validate is the actual implementation of Validate. 141 + func validate(c *adt.OpContext, b []byte, v pkg.Schema) (bool, error) { 137 142 if !json.Valid(b) { 138 143 return false, fmt.Errorf("json: invalid JSON") 139 144 }
+1 -1
pkg/encoding/json/pkg.go
··· 123 123 Func: func(c *pkg.CallCtxt) { 124 124 b, v := c.Bytes(0), c.Schema(1) 125 125 if c.Do() { 126 - c.Ret, c.Err = Validate(b, v) 126 + c.Ret, c.Err = validate(c.OpContext(), b, v) 127 127 } 128 128 }, 129 129 }},
+1 -1
pkg/encoding/json/testdata/gen.txtar
··· 116 116 schema: { 117 117 a: <3 118 118 } 119 - result: _|_ // validate.t2.result: error in call to encoding/json.Validate: validate.t2.schema.a: invalid value 10 (out of bound <3) 119 + result: _|_ // validate.t2.result: error in call to encoding/json.Validate: validate.t2.result.a: invalid value 10 (out of bound <3) 120 120 } 121 121 disjunctionRequired: { 122 122 str: *"{\"a\":10}" | string
+17
pkg/encoding/yaml/manual.go
··· 20 20 21 21 "cuelang.org/go/cue" 22 22 "cuelang.org/go/cue/ast" 23 + "cuelang.org/go/internal/core/adt" 23 24 cueyaml "cuelang.org/go/internal/encoding/yaml" 24 25 "cuelang.org/go/internal/pkg" 25 26 "cuelang.org/go/internal/value" ··· 87 88 // Validate validates YAML and confirms it is an instance of schema. 88 89 // If the YAML source is a stream, every object must match v. 89 90 func Validate(b []byte, v pkg.Schema) (bool, error) { 91 + // This function is left for Go documentation. The package entry calls 92 + // cueyaml.Validate directly, passing it the call context. 93 + 90 94 ctx := value.OpContext(v) 91 95 return cueyaml.Validate(ctx, b, v) 96 + } 97 + 98 + // validate is the actual implementation of Validate. 99 + func validate(c *adt.OpContext, b []byte, v pkg.Schema) (bool, error) { 100 + return cueyaml.Validate(c, b, v) 92 101 } 93 102 94 103 // ValidatePartial validates YAML and confirms it matches the constraints ··· 96 105 // but does not have to be an instance of v. If the YAML source is a stream, 97 106 // every object must match v. 98 107 func ValidatePartial(b []byte, v pkg.Schema) (bool, error) { 108 + // This function is left for Go documentation. The package entry calls 109 + // cueyaml.ValidatePartial directly, passing it the call context. 110 + 99 111 ctx := value.OpContext(v) 100 112 return cueyaml.ValidatePartial(ctx, b, v) 101 113 } 114 + 115 + // validatePartial is the actual implementation of ValidatePartial. 116 + func validatePartial(c *adt.OpContext, b []byte, v pkg.Schema) (bool, error) { 117 + return cueyaml.ValidatePartial(c, b, v) 118 + }
+2 -2
pkg/encoding/yaml/pkg.go
··· 73 73 Func: func(c *pkg.CallCtxt) { 74 74 b, v := c.Bytes(0), c.Schema(1) 75 75 if c.Do() { 76 - c.Ret, c.Err = Validate(b, v) 76 + c.Ret, c.Err = validate(c.OpContext(), b, v) 77 77 } 78 78 }, 79 79 }, { ··· 87 87 Func: func(c *pkg.CallCtxt) { 88 88 b, v := c.Bytes(0), c.Schema(1) 89 89 if c.Do() { 90 - c.Ret, c.Err = ValidatePartial(b, v) 90 + c.Ret, c.Err = validatePartial(c.OpContext(), b, v) 91 91 } 92 92 }, 93 93 }},
+3 -3
pkg/encoding/yaml/testdata/gen.txtar
··· 51 51 ./in.cue:28:11 52 52 53 53 Result: 54 - t1: _|_ // t1: error in call to encoding/yaml.Validate: a: invalid value 4 (out of bound <3) 54 + t1: _|_ // t1: error in call to encoding/yaml.Validate: t1.a: invalid value 4 (out of bound <3) 55 55 t2: true 56 - t3: _|_ // t3: error in call to encoding/yaml.Validate: b: incomplete value int 57 - t4: _|_ // t4: error in call to encoding/yaml.ValidatePartial: a: invalid value 4 (out of bound <3) 56 + t3: _|_ // t3: error in call to encoding/yaml.Validate: t3.b: incomplete value int 57 + t4: _|_ // t4: error in call to encoding/yaml.ValidatePartial: t4.a: invalid value 4 (out of bound <3) 58 58 t5: true 59 59 t6: true 60 60 t7: """
+1 -1
pkg/encoding/yaml/testdata/validate.txtar
··· 79 79 // TODO: fix this test: the second disjunct should be eliminated, so there 80 80 // should not be a concreteness error. 81 81 t1: { 82 - ok1: _|_ // validate.t1.ok1: invalid value "a: 2" (does not satisfy encoding/yaml.Validate): validate.t1.ok1: error in call to encoding/yaml.Validate: incomplete value {a:2} | {a:2,b!:int} 82 + ok1: _|_ // validate.t1.ok1: invalid value "a: 2" (does not satisfy encoding/yaml.Validate): validate.t1.ok1: error in call to encoding/yaml.Validate: validate.t1.ok1: incomplete value {a:2} | {a:2,b!:int} 83 83 ok2: "a: 2" 84 84 ok3: "a: 2" 85 85 }
+19 -3
pkg/gen.go
··· 338 338 339 339 fmt.Fprintf(g.w, "Name: %q,\n", fn.Name()) 340 340 341 + needCallContext := false 341 342 args := []string{} 342 343 vals := []string{} 343 344 kind := []string{} 344 345 for i := 0; i < params.Len(); i++ { 345 346 param := params.At(i) 346 - methodName := g.callCtxtGetter(param.Type()) 347 + typ := param.Type() 348 + if typ.String() == "cuelang.org/go/internal/pkg.Schema" { 349 + needCallContext = true 350 + } 351 + methodName := g.callCtxtGetter(typ) 347 352 argKind := g.adtKind(param.Type()) 348 353 vals = append(vals, fmt.Sprintf("c.%s(%d)", methodName, len(args))) 349 354 args = append(args, param.Name()) ··· 368 373 init = fmt.Sprintf("%s := %s", argList, valList) 369 374 } 370 375 376 + name := fn.Name() 377 + if needCallContext { 378 + argList = "c.OpContext(), " + argList 379 + 380 + // Main function is used for Godoc documentation. Once we have proper 381 + // CUE function signatures, we can remove these stubs. 382 + // NOTE: this will not work for scripts that are not cased. But this 383 + // is intended to be a temporary situation anyway. 384 + name = strings.ToLower(name[:1]) + name[1:] 385 + } 386 + 371 387 fmt.Fprintf(g.w, "Func: func(c *pkg.CallCtxt) {") 372 388 defer fmt.Fprintln(g.w, "},") 373 389 fmt.Fprintln(g.w) ··· 377 393 fmt.Fprintln(g.w, "if c.Do() {") 378 394 defer fmt.Fprintln(g.w, "}") 379 395 if results.Len() == 1 { 380 - fmt.Fprintf(g.w, "c.Ret = %s(%s)", fn.Name(), argList) 396 + fmt.Fprintf(g.w, "c.Ret = %s(%s)", name, argList) 381 397 } else { 382 - fmt.Fprintf(g.w, "c.Ret, c.Err = %s(%s)", fn.Name(), argList) 398 + fmt.Fprintf(g.w, "c.Ret, c.Err = %s(%s)", name, argList) 383 399 } 384 400 } 385 401
+6 -1
pkg/list/list.go
··· 333 333 // Likewise, "matchValue" will usually be a non-concrete value. 334 334 func MatchN(list []cue.Value, n pkg.Schema, matchValue pkg.Schema) (bool, error) { 335 335 c := value.OpContext(n) 336 + return matchN(c, list, n, matchValue) 337 + } 338 + 339 + // matchN is the actual implementation of MatchN. 340 + func matchN(c *adt.OpContext, list []cue.Value, n pkg.Schema, matchValue pkg.Schema) (bool, error) { 336 341 var nmatch int64 337 342 for _, w := range list { 338 343 vx := adt.Unify(c, value.Vertex(matchValue), value.Vertex(w)) ··· 342 347 } 343 348 } 344 349 345 - ctx := value.Context(n) 350 + ctx := value.Context(c) 346 351 347 352 if err := n.Unify(ctx.Encode(nmatch)).Err(); err != nil { 348 353 return false, pkg.ValidationError{B: &adt.Bottom{
+1 -1
pkg/list/pkg.go
··· 167 167 Func: func(c *pkg.CallCtxt) { 168 168 list, n, matchValue := c.List(0), c.Schema(1), c.Schema(2) 169 169 if c.Do() { 170 - c.Ret, c.Err = MatchN(list, n, matchValue) 170 + c.Ret, c.Err = matchN(c.OpContext(), list, n, matchValue) 171 171 } 172 172 }, 173 173 }, {