this repo has no description
0
fork

Configure Feed

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

doc/ref: fix three mistakes in the matchIf examples

The second and third examples used four arguments instead of three;
the label on the left side of the field declaration was repeated
as the first argument, almost like it was a receiver parameter.

The second example was also not behaving as documented,
because the line after the fix above would still succeed `cue export`.
This is because `b` was not actually a required field,
so `{a: 1} & {a: int, b: int}` succeeds and passes the validation.
Make the `b` field required to match the intented behavior in the docs.

Finally, the results of these unifications are not booleans;
rather than noting each of the expected outcomes as `true` or `false`,
use the words "OK" or "error", and consistently say why.

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

+3 -3
+3 -3
doc/ref/spec.md
··· 2870 2870 2871 2871 ``` 2872 2872 // If value is a string, it must have length > 3; otherwise it must be > 10 2873 - value: "hello" & matchIf(string, len(value) > 3, value > 10) // true 2873 + value: "hello" & matchIf(string, len(value) > 3, value > 10) // OK; len("hello") is >3 2874 2874 2875 2875 // If value matches {a: int}, it must have b field; otherwise a must be a string 2876 - x: {a: 1} & matchIf(x, {a: int}, {a: int, b: int}, {a: string}) // false: missing b 2876 + x: {a: 1} & matchIf({a: int}, {a: int, b!: int}, {a: string}) // error; missing field b 2877 2877 2878 2878 // If value is >5, it must be <10; otherwise it must be <3 2879 - y: 2 & matchIf(y, >5, <10, <3) // true: 2 is <=5, so <3 is checked 2879 + y: 2 & matchIf(>5, <10, <3) // OK; 2 is <3 2880 2880 ``` 2881 2881 2882 2882