docs: Note that tryEval doesn't do deep evaluation

(cherry picked from commit e4ea3e03066a760c8cd462108af99aebaaa44c1b)
This commit is contained in:
Silvan Mosberger 2019-09-03 07:32:44 +02:00 committed by Eelco Dolstra
parent fa028194e9
commit 7c9ad4d0d7
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -1605,12 +1605,18 @@ stdenv.mkDerivation (rec {
<term><function>builtins.tryEval</function> <term><function>builtins.tryEval</function>
<replaceable>e</replaceable></term> <replaceable>e</replaceable></term>
<listitem><para>Try to evaluate <replaceable>e</replaceable>. <listitem><para>Try to shallowly evaluate <replaceable>e</replaceable>.
Return a set containing the attributes <literal>success</literal> Return a set containing the attributes <literal>success</literal>
(<literal>true</literal> if <replaceable>e</replaceable> evaluated (<literal>true</literal> if <replaceable>e</replaceable> evaluated
successfully, <literal>false</literal> if an error was thrown) and successfully, <literal>false</literal> if an error was thrown) and
<literal>value</literal>, equalling <replaceable>e</replaceable> <literal>value</literal>, equalling <replaceable>e</replaceable>
if successful and <literal>false</literal> otherwise. if successful and <literal>false</literal> otherwise. Note that this
doesn't evaluate <replaceable>e</replaceable> deeply, so
<literal>let e = { x = throw ""; }; in (builtins.tryEval e).success
</literal> will be <literal>true</literal>. Using <literal>builtins.deepSeq
</literal> one can get the expected result: <literal>let e = { x = throw "";
}; in (builtins.tryEval (builtins.deepSeq e e)).success</literal> will be
<literal>false</literal>.
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>