Vikingman has quit [Read error: Connection reset by peer]
kyren has quit [Ping timeout: 256 seconds]
ddellacosta has quit [Ping timeout: 264 seconds]
ddellacosta has joined #nix-lang
<infinisil>
> let exists = _: if result ? key then "exists" else "doesn't"; result = { ${exists 0} = null; ${"key" + ""} = null; ${exists 0} = null; }; in result
<infinisil>
> let exists = _: if result ? key then "exists" else "doesn't"; result = { ${exists 0} = null; ${exists 0} = null; ${"key" + ""} = null; }; in result
<{^_^}>
dynamic attribute 'doesn't' at (string):292:94 already defined at (string):292:74
<infinisil>
I think dynamic attribute keys in general is the problematic feature
<puck>
dw, i can have dynamic attribute keys without dynamic attribute keys
<puck>
:p
<puck>
> let makeAttr = name: value: import (builtins.toFile "a" "value: { ${builtins.toJSON name} = value; }") value; in makeAttr "foo" "bar"
<{^_^}>
cannot import '/nix/store/4sjqj2nnmhylsncdq2l534149w75sh9y-a', since path '/nix/store/4sjqj2nnmhylsncdq2l534149w75sh9y-a' is not valid, at (string):292:29
<puck>
thanks {`-`}_
<puck>
err
<puck>
thanks {^_^}
<puck>
(read-only store :( )
bachp has joined #nix-lang
<puck>
also this is not completely functional in general, obvs
<infinisil>
Hehe
<puck>
tbh i'm not sure there's anything in nixlang that would really surprise me anymore
<infinisil>
puck: But I think just `builtins.listToAttrs` would work
<puck>
infinisil: ssh
<infinisil>
Yeah nix has some weird corners
<puck>
infinisil: i assume you've seen the weirdness with rec and non-rec
<infinisil>
Possibly
<puck>
> let a = rec {}; b = 5; a.b = b; in a.b
<{^_^}>
infinite recursion encountered, at (string):292:30
<puck>
or even weirder
<infinisil>
Oh yeah, but I don't know what's going on
<puck>
> let a = rec {}; a = {}; b = 5; a.b = b; in a.b
<{^_^}>
infinite recursion encountered, at (string):292:38
<puck>
recness of an attrset is defined once it is first declared, and the shorthand for attrset building does not handle this properly
<puck>
i'm not entirely certain this is easily fixable in Nix
<infinisil>
I feel like that expression should just give an error that a is assigned multiple times
<puck>
except
<puck>
hrm
<puck>
like, this is continuation of attrset shorthands
<puck>
e.g. > let a = { b = 5; }; a.c = 7; in a
<puck>
is valid
<infinisil>
Hm
<infinisil>
Maybe rec shouldn't be allowed to take part in this
<puck>
that'd probably break things that exist already
<infinisil>
Eh
<puck>
it shouldn't be too hard (is it? idk) to throw a warning when this generates a conflicting scope tho
<infinisil>
Wait wouldn't it make sense for `rec {} == {}`?
<infinisil>
> let a = rec {}; a = {}; b = 5; a.b = b; in a.b
<{^_^}>
infinite recursion encountered, at (string):292:38
<infinisil>
> let a = {}; a = {}; b = 5; a.b = b; in a.b
<{^_^}>
5
<infinisil>
Have a rewrite pass, that transforms all recs into non-rec variants
<infinisil>
> rec { a = 10; b = a; }
<{^_^}>
{ a = 10; b = 10; }
<infinisil>
> let a = 10; b = a; in { inherit a b; } # Turns into this
<{^_^}>
{ a = 10; b = 10; }
<puck>
this isn't too hard to do in general but definitely in the current nix codebase