about summary refs log tree commit diff
path: root/tvix/eval/src/tests/tvix_tests/eval-okay-formals-miscompilation-b-261-regression.nix
blob: 772fa6f386b3082800cde1835e3017c13ff64026 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# This is a regression test for https://b.tvl.fyi/261.
#
# The bug occurred when Tvix would unconditionally finalise the stack slot of
# `finalise` (as its default expression needs a finaliser): Finalising an
# manually provided, already forced thunk would cause the VM to crash.
let
  thunk = x: x;
  bomb = thunk true;
  f =
    { finalise ? later == null
    , later ? null
    }:
    [ finalise later ];
in

# Note that the crash did not occur if the offending expression was the rhs
  # argument to `builtins.seq`, hence we need to put the assert in between.
assert builtins.seq bomb true;

f { finalise = bomb; }