-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse mixed nested attrpaths and top-level sets in an order independant way #2089
Conversation
@NinjaTrappeur Thanks so much for this! I actually think we should fail in both directions, not succeed... That is, we should have a copy of |
(I think the existence of that test case is further evidence that #2077 should be a bug 😀 ) |
Mmh, I am a bit confused here. I though that |
No, you're correct. But mixing declaration styles like the test suite example does is confusing and unnecessary, it's better not to support it at all. Either use one or the other. This becomes especially apparent in larger sets. If I see |
Alright, I understand, it practically makes sense. However, I had a bad intuition about this, I just wrote a short patch roughly implementing this behavior.
Note I did not implement a proper error handling, I was just trying to detect the missing case. Basically, in order to detect those cases, we need to differentiate Personally, I find making a difference between those two notations highly confusing. I don't like the idea of having two different semantics depending on the fact we are using or not a syntactic sugar form, I am more in favor of allowing mixed nested attrpaths altogether. In the end, I don't really care, this is a corner case I never encountered so far :) [edit april 2019] I actually encountered this corner case several times in the last year. I changed my mind: I care about this. If we decide to prohibit mixed nested attrpaths, I'll close this pr, implement a proper error handling and will submit the above patch in another PR. That way, we'll still have this PR if we change our mind at some point in the future. I think it would also be nice to document this corner case in the nix manual if we decide to go that way. |
@edolstra Can you make a call here? IMO mixing declarations is just begging for confusion. |
Probably it would have been better to disallow both cases from the start, but we probably don't want to break backwards compatibility. So from that perspective, it's cleaner to accept both. Does this PR merge nested attrsets at arbitrary depths, e.g.
? |
Yes. I just added this test case to this PR.
I have a loosely-related question: is there any way to run a CI (hydra?) on a PR? |
Unfortunately not unless you have powers over Hydra. There's a thread on getting Travis support (#1152) but it's stalled. |
What's the status of this? Is this good to merge? |
It is. The feature is tested. I can rebase the branch if needed. I've been bitten by this particular issue several times since I pushed this PR. |
Thanks, merged! |
Hi,
This PR implements #2077. I also added some test cases.
I am a bit confused about
tests/lang/parse-fail-dup-attrs-6.nix
.To me, it clearly looks like the case shown in issue #2077.
Did we simply forget we should not allow mixed attrPaths and forgot to throw an error for the other way around? I am maybe missing something obvious here :).
On a side-note, from an outsider perspective, the addAttr function was confusing. I feel like it could be divided into two functions. I was unsure about this, I just added some comments.