Skip to content

Commit

Permalink
internal/core: finalize list in slice
Browse files Browse the repository at this point in the history
Fixes #500

Change-Id: Iecd8f46c36c1765b86d1d86a917d0a0889786a09
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7042
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Sep 12, 2020
1 parent 8776561 commit a6ce869
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
82 changes: 82 additions & 0 deletions cue/testdata/eval/issue500.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
-- in.cue --
package x

import "strings"

a: strings.Join(strings.Split("test", "")[1:], "")

b: strings.Join(["t", "e", "s", "t"][1:], "")

c: ["t", "e", "s", "t"][1:]
d: strings.Join(c, "")

e: strings.Join(["a"] + ["b"], "")

f: ["a"] + ["b"]
g: strings.Join(f, "")

h: strings.Join(3*["a"], "")

i: 3 * ["b"]
j: strings.Join(i, "")

-- out/eval --
(struct){
a: (string){ "est" }
b: (string){ "est" }
c: (#list){
0: (string){ "e" }
1: (string){ "s" }
2: (string){ "t" }
}
d: (string){ "est" }
e: (string){ "ab" }
f: (#list){
0: (string){ "a" }
1: (string){ "b" }
}
g: (string){ "ab" }
h: (string){ "aaa" }
i: (#list){
0: (string){ "b" }
1: (string){ "b" }
2: (string){ "b" }
}
j: (string){ "bbb" }
}
-- out/compile --
--- in.cue
{
a: 〈import;strings〉.Join(〈import;strings〉.Split("test", "")[1:], "")
b: 〈import;strings〉.Join([
"t",
"e",
"s",
"t",
][1:], "")
c: [
"t",
"e",
"s",
"t",
][1:]
d: 〈import;strings〉.Join(〈0;c〉, "")
e: 〈import;strings〉.Join(([
"a",
] + [
"b",
]), "")
f: ([
"a",
] + [
"b",
])
g: 〈import;strings〉.Join(〈0;f〉, "")
h: 〈import;strings〉.Join((3 * [
"a",
]), "")
i: (3 * [
"b",
])
j: 〈import;strings〉.Join(〈0;i〉, "")
}
1 change: 1 addition & 0 deletions internal/core/adt/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ func (x *SliceExpr) evaluate(c *OpContext) Value {
Conjuncts: a.Conjuncts,
})
}
n.status = Finalized
return n

case *Bytes:
Expand Down

0 comments on commit a6ce869

Please sign in to comment.