From b667b4cded1b9d974157f27761d8648b372d27bf Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Fri, 8 Mar 2024 09:52:15 +0100 Subject: evaluate inherit (from) exprs only once per directive desugaring inherit-from to syntactic duplication of the source expr also duplicates side effects of the source expr (such as trace calls) and expensive computations (such as derivationStrict). (cherry picked from commit cefd0302b55b3360dbca59cfcb4bf6a750d6cdcf) Change-Id: Iff519f991adef2e51683ba2c552d37a3df7a179e --- tests/functional/lang/eval-okay-inherit-from.err.exp | 1 - tests/functional/lang/eval-okay-inherit-from.exp | 2 +- tests/functional/lang/eval-okay-inherit-from.nix | 12 +++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'tests/functional/lang') diff --git a/tests/functional/lang/eval-okay-inherit-from.err.exp b/tests/functional/lang/eval-okay-inherit-from.err.exp index 51881205b..3227501f2 100644 --- a/tests/functional/lang/eval-okay-inherit-from.err.exp +++ b/tests/functional/lang/eval-okay-inherit-from.err.exp @@ -1,2 +1 @@ trace: used -trace: used diff --git a/tests/functional/lang/eval-okay-inherit-from.exp b/tests/functional/lang/eval-okay-inherit-from.exp index 43bd0e899..024daff6b 100644 --- a/tests/functional/lang/eval-okay-inherit-from.exp +++ b/tests/functional/lang/eval-okay-inherit-from.exp @@ -1 +1 @@ -[ 1 2 { __overrides = { y = { d = [ ]; }; }; c = [ ]; d = 4; x = { c = [ ]; }; y = «repeated»; } ] +[ 1 2 { __overrides = { y = { d = [ ]; }; }; c = [ ]; d = 4; x = { c = [ ]; }; y = «repeated»; } { inner = { c = 3; d = 4; }; } ] diff --git a/tests/functional/lang/eval-okay-inherit-from.nix b/tests/functional/lang/eval-okay-inherit-from.nix index d1fad7d69..b72a1c639 100644 --- a/tests/functional/lang/eval-okay-inherit-from.nix +++ b/tests/functional/lang/eval-okay-inherit-from.nix @@ -2,5 +2,15 @@ let inherit (builtins.trace "used" { a = 1; b = 2; }) a b; x.c = 3; y.d = 4; + + merged = { + inner = { + inherit (y) d; + }; + + inner = { + inherit (x) c; + }; + }; in - [ a b rec { x.c = []; inherit (x) c; inherit (y) d; __overrides.y.d = []; } ] + [ a b rec { x.c = []; inherit (x) c; inherit (y) d; __overrides.y.d = []; } merged ] -- cgit v1.2.3