Skip to content
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

Assertion syntax in error in the manual? #3388

Closed
wants to merge 1 commit into from
Closed

Conversation

@mayl
Copy link

mayl commented Mar 7, 2020

I'm a complete neophyte to Nix, but based on the example in the manual and looking in nixpkgs a bit it seems like the actual assert syntax is assert e1 -> e2 not assert e1; e2. If I've got this garbled, please ignore of course, but even if so I think it's still worth pointing out that for a new learner this explanation and example seem contradictory as written and could probably be clarified.

I'm a complete neophyte to Nix, but based on the example in manual and looking in `nixpkgs` a bit it seems like the actual `assert` syntax is `assert e1 -> e2`  not `assert e1; e2`.  If I'm got this garbled, please ignore of course, but even if so I think it's still worth pointing out that for a new learner this explanation and example _seem_ contradictory_  as written and could probably be clarified.
@LnL7
Copy link
Member

LnL7 commented Mar 7, 2020

While very often used together, assert and -> (implication) are separate things.

nix-repl> assert true; 42
42

nix-repl> assert false; 42
error: assertion 'false' failed at (string):1:1
nix-repl> true -> 1 > 2
false
nix-repl> false -> 1 > 2
true
@mayl
Copy link
Author

mayl commented Mar 7, 2020

Ok, I see. Thanks for clarifying. I guess part of what made this confusing for me is that the implication operator isn't introduced until after assert is described, and then every assert example uses it without further explanation. I'm sure this is much more obvious to users with a stronger functional programming background than me.

@mayl mayl closed this Mar 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.