| 1 Dec 2025 |
niko ⚡️ | A valid functor could also be __functor = _: _: _: _: _: _: 1. That's whatever, but if it's a function that does not return a function, like __functor = _: {}, you can't call it! | 08:04:33 |
piegames | I'd say the theory agrees with you, but I wouldn't bet on the code doing the sane thing until I've seen it | 08:53:39 |
piegames | https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/eval.cc#L1762 at last callFunction requires the functor to take to arguments, so any deviation from that must come from some autocall jank | 09:02:55 |
piegames | https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/eval.cc#L1820 indeed, autoCallFunction only calls __functor with one single argument | 09:05:32 |
piegames | @niko:nrab.lol can you please file an issue for your finding? So that I don't forget it when I'll come around to sanitizing the autocaller | 09:06:42 |
piegames | In reply to @piegames:flausch.social https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/eval.cc#L1820 indeed, autoCallFunction only calls __functor with one single argument Well, it does the right thing in spirit, because it directly recurses so if the functor takes two arguments as usual then the code will behave correctly. It's just that if it isn't, there is an early return from the recursion which prevents the code path that would be inspecting the inner function | 09:08:10 |
piegames | One interesting question is what to do with a functor like { __functor = self: b: 1; }, where the inner lambda does not destructure its attributes and thus cannot be autocalled. The probably correct result would be b: 1, which might be confusing. The alternative would be to only treat the functor as a function when it applies and thus leave the attrset unchanged, but that might be another can of worms | 09:11:31 |
niko ⚡️ | In reply to @piegames:flausch.social One interesting question is what to do with a functor like { __functor = self: b: 1; }, where the inner lambda does not destructure its attributes and thus cannot be autocalled. The probably correct result would be b: 1, which might be confusing. The alternative would be to only treat the functor as a function when it applies and thus leave the attrset unchanged, but that might be another can of worms I really don’t like how __functor = _: _: 1 and __functor = _: {...}@_: 1 have different auto-call semantics | 09:15:58 |
niko ⚡️ | Can we like, not auto-call functors in the first place? And kill deep auto-calls while we’re at it? :^) | 09:17:25 |
niko ⚡️ | In reply to @piegames:flausch.social @niko:nrab.lol can you please file an issue for your finding? So that I don't forget it when I'll come around to sanitizing the autocaller It is done | 09:45:35 |
piegames | In reply to @niko:nrab.lol I really don’t like how __functor = _: _: 1 and __functor = _: {...}@_: 1 have different auto-call semantics To be fair these have subtly different semantics even outside of auto-calling, so I would argue that bit not to be an auto-call issue | 09:53:59 |
niko ⚡️ | In reply to @piegames:flausch.social To be fair these have subtly different semantics even outside of auto-calling, so I would argue that bit not to be an auto-call issue I think asserting an argument is an attrset is on a different level to whether autocalling takes place or not | 09:54:53 |
niko ⚡️ | At least I’d personally expect all functions to be auto-called, or none | 09:55:17 |
piegames | In reply to @niko:nrab.lol At least I’d personally expect all functions to be auto-called, or none Well that's already not the case unfortunately https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/eval.cc#L1831 | 10:05:20 |
niko ⚡️ | In reply to @piegames:flausch.social Well that's already not the case unfortunately https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/eval.cc#L1831 Oh I know, I’m very much not a fan of auto-calling in the first place, but even my bias aside it has a bunch of sharp edges besides e.g. the blatant bug with functors | 10:08:17 |
piegames | Honestly auto-calling should be ripped out and replaced with some dedicated parametrized top-level entry point mechanism | 10:19:33 |
piegames | And functors, sigh | 10:19:48 |
helle (just a stray cat girl) | auto-calling is scary stuff imo | 10:28:24 |
piegames | Unfortunately I'm a pretty big user of it :D | 11:09:11 |
piegames | It's great when you're using Nix as a data pipeline scripting language | 11:09:30 |
raitobezarius | nixpkgs and normal package uses a lot of autocalls as well | 11:32:14 |
raitobezarius | but simple shallow autocalls usually | 11:32:22 |
raitobezarius | it would make sense for flaker maybe to support measuring the depthness of the autocalls | 11:32:30 |
raitobezarius | for non-flakes entrypoints i suppose | 11:32:35 |
piegames | Can this be done with static analysis? | 11:33:36 |
raitobezarius | i don't believe so | 11:33:44 |
piegames | Can you give some examples? | 11:33:58 |
raitobezarius | we must hook some reporting facility in lix that you can exploit | 11:33:53 |
raitobezarius | old-style tests entrypoints | 11:34:08 |
raitobezarius | in nixpkgs | 11:34:13 |