File: 007_strings_and_bytes.txtar

package info (click to toggle)
golang-github-cue-lang-cue 0.14.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,644 kB
  • sloc: makefile: 20; sh: 15
file content (78 lines) | stat: -rw-r--r-- 1,853 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#name: strings and bytes
#evalPartial
-- in.cue --
s0: "foo" + "bar"
s1: 3 * "abc"
s2: "abc" * 2

b0: 'foo' + 'bar'
b1: 3 * 'abc'
b2: 'abc' * 2

// TODO: consider the semantics of this and perhaps allow this.
e0: "a" + ''
e1: 'b' + "c"
-- out/def --
s0: "foobar"
s1: "abcabcabc"
s2: "abcabc"
b0: 'foobar'
b1: 'abcabcabc'
b2: 'abcabc'

// TODO: consider the semantics of this and perhaps allow this.
e0: _|_ // invalid operation "a" + '' (mismatched types string and bytes)
e1: _|_ // invalid operation 'b' + "c" (mismatched types bytes and string)
-- out/legacy-debug --
<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))}
-- out/compile --
--- in.cue
{
  s0: ("foo" + "bar")
  s1: (3 * "abc")
  s2: ("abc" * 2)
  b0: ('foo' + 'bar')
  b1: (3 * 'abc')
  b2: ('abc' * 2)
  e0: ("a" + '')
  e1: ('b' + "c")
}
-- out/eval/stats --
Leaks:  0
Freed:  9
Reused: 7
Allocs: 2
Retain: 0

Unifications: 9
Conjuncts:    9
Disjuncts:    9
-- out/eval --
Errors:
e0: invalid operands "a" and '' to '+' (type string and bytes):
    ./in.cue:10:5
    ./in.cue:10:11
e1: invalid operands 'b' and "c" to '+' (type bytes and string):
    ./in.cue:11:5
    ./in.cue:11:11

Result:
(_|_){
  // [eval]
  s0: (string){ "foobar" }
  s1: (string){ "abcabcabc" }
  s2: (string){ "abcabc" }
  b0: (bytes){ 'foobar' }
  b1: (bytes){ 'abcabcabc' }
  b2: (bytes){ 'abcabc' }
  e0: (_|_){
    // [eval] e0: invalid operands "a" and '' to '+' (type string and bytes):
    //     ./in.cue:10:5
    //     ./in.cue:10:11
  }
  e1: (_|_){
    // [eval] e1: invalid operands 'b' and "c" to '+' (type bytes and string):
    //     ./in.cue:11:5
    //     ./in.cue:11:11
  }
}