fix(tvix/eval): use coerce_to_string in builtins.substring
This actually uses coercion under the hood in C++ Nix. See the test for an example. Change-Id: Id56b364acf269225b6829d0b600e0222f8b3608d Reviewed-on: https://cl.tvl.fyi/c/depot/+/8322 Reviewed-by: andi <andi@notmuch.email> Tested-by: BuildkiteCI
This commit is contained in:
parent
68d287fd82
commit
b78ae941a4
3 changed files with 7 additions and 1 deletions
|
@ -835,7 +835,7 @@ mod pure_builtins {
|
||||||
) -> Result<Value, ErrorKind> {
|
) -> Result<Value, ErrorKind> {
|
||||||
let beg = start.as_int()?;
|
let beg = start.as_int()?;
|
||||||
let len = len.as_int()?;
|
let len = len.as_int()?;
|
||||||
let x = s.to_str()?;
|
let x = s.coerce_to_string(co, CoercionKind::Weak).await?.to_str()?;
|
||||||
|
|
||||||
if beg < 0 {
|
if beg < 0 {
|
||||||
return Err(ErrorKind::IndexOutOfBounds { index: beg });
|
return Err(ErrorKind::IndexOutOfBounds { index: beg });
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
"42"
|
|
@ -0,0 +1,5 @@
|
||||||
|
# builtins.substring uses string coercion internally
|
||||||
|
|
||||||
|
builtins.substring 0 2 {
|
||||||
|
__toString = _: "4200";
|
||||||
|
}
|
Loading…
Reference in a new issue