cuelang.org/go@v0.13.0/cue/testdata/basicrewrite/007_strings_and_bytes.txtar (about)

     1  #name: strings and bytes
     2  #evalPartial
     3  -- in.cue --
     4  s0: "foo" + "bar"
     5  s1: 3 * "abc"
     6  s2: "abc" * 2
     7  
     8  b0: 'foo' + 'bar'
     9  b1: 3 * 'abc'
    10  b2: 'abc' * 2
    11  
    12  // TODO: consider the semantics of this and perhaps allow this.
    13  e0: "a" + ''
    14  e1: 'b' + "c"
    15  -- out/def --
    16  s0: "foobar"
    17  s1: "abcabcabc"
    18  s2: "abcabc"
    19  b0: 'foobar'
    20  b1: 'abcabcabc'
    21  b2: 'abcabc'
    22  
    23  // TODO: consider the semantics of this and perhaps allow this.
    24  e0: _|_ // invalid operation "a" + '' (mismatched types string and bytes)
    25  e1: _|_ // invalid operation 'b' + "c" (mismatched types bytes and string)
    26  -- out/legacy-debug --
    27  <0>{s0: "foobar", s1: "abcabcabc", s2: "abcabc", b0: 'foobar', b1: 'abcabcabc', b2: 'abcabc', e0: _|_(("a" + ''):invalid operation "a" + '' (mismatched types string and bytes)), e1: _|_(('b' + "c"):invalid operation 'b' + "c" (mismatched types bytes and string))}
    28  -- out/compile --
    29  --- in.cue
    30  {
    31    s0: ("foo" + "bar")
    32    s1: (3 * "abc")
    33    s2: ("abc" * 2)
    34    b0: ('foo' + 'bar')
    35    b1: (3 * 'abc')
    36    b2: ('abc' * 2)
    37    e0: ("a" + '')
    38    e1: ('b' + "c")
    39  }
    40  -- out/eval/stats --
    41  Leaks:  0
    42  Freed:  9
    43  Reused: 7
    44  Allocs: 2
    45  Retain: 0
    46  
    47  Unifications: 9
    48  Conjuncts:    9
    49  Disjuncts:    9
    50  -- out/eval --
    51  Errors:
    52  e0: invalid operands "a" and '' to '+' (type string and bytes):
    53      ./in.cue:10:5
    54      ./in.cue:10:11
    55  e1: invalid operands 'b' and "c" to '+' (type bytes and string):
    56      ./in.cue:11:5
    57      ./in.cue:11:11
    58  
    59  Result:
    60  (_|_){
    61    // [eval]
    62    s0: (string){ "foobar" }
    63    s1: (string){ "abcabcabc" }
    64    s2: (string){ "abcabc" }
    65    b0: (bytes){ 'foobar' }
    66    b1: (bytes){ 'abcabcabc' }
    67    b2: (bytes){ 'abcabc' }
    68    e0: (_|_){
    69      // [eval] e0: invalid operands "a" and '' to '+' (type string and bytes):
    70      //     ./in.cue:10:5
    71      //     ./in.cue:10:11
    72    }
    73    e1: (_|_){
    74      // [eval] e1: invalid operands 'b' and "c" to '+' (type bytes and string):
    75      //     ./in.cue:11:5
    76      //     ./in.cue:11:11
    77    }
    78  }