fix(tvix/eval): make sure to deref thunk in type predicate builtins

Previously we only matched the outer constructor after forcing which
would mean that we would always return `false` if the inspected value
was a thunk, regardless what value would be present inside.

Change-Id: I361ea6e855e23ef8e5b59098a50b9cd59253803f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6692
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
This commit is contained in:
sterni 2022-09-19 11:47:34 +02:00
parent fe3c4720a6
commit e04ccc9354
3 changed files with 63 additions and 18 deletions

View file

@ -0,0 +1 @@
[ true true false true true false true true false true true false true true false true true false true true false true true false true true true false ]

View file

@ -0,0 +1,34 @@
let
# apply is thunked, so we can create a thunked value using the identity function
thunk = x: x;
in
[
(builtins.isAttrs { bar = throw "baz"; })
(builtins.isAttrs (thunk { foo = 13; }))
(builtins.isAttrs (thunk 123))
(builtins.isBool true)
(builtins.isBool (thunk false))
(builtins.isBool (thunk "lol"))
(builtins.isFloat 1.2)
(builtins.isFloat (thunk (1 * 1.0)))
(builtins.isFloat 1)
(builtins.isFunction thunk)
(builtins.isFunction (thunk thunk))
(builtins.isFunction {})
(builtins.isInt 1)
(builtins.isInt (thunk 42))
(builtins.isInt 1.0)
(builtins.isList [ (throw "oh no") (abort "it's over") ])
(builtins.isList (thunk [ 21 21 ]))
(builtins.isList (thunk {}))
(builtins.isNull null)
(builtins.isNull (thunk null))
(builtins.isNull 42)
(builtins.isPath ./relative)
(builtins.isPath (thunk /absolute))
(builtins.isPath "/not/a/path")
(builtins.isString "simple")
(builtins.isString "${{ outPath = "coerced"; }}")
(builtins.isString "hello ${"interpolation"}")
(builtins.isString true)
]