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

When is a koan not a contradiction? #37

Open
sethp opened this issue Sep 20, 2018 · 1 comment
Open

When is a koan not a contradiction? #37

sethp opened this issue Sep 20, 2018 · 1 comment

Comments

@sethp
Copy link

sethp commented Sep 20, 2018

Hi! I'm seeing something very strange as I'm working through the koans. It's probably not a bug with the koans per se, so feel free to direct me to a more appropriate place but: I only see test failures on even koans, but the even koans' failures include the odd failures.

Let me explain. I start as so:

$ tail src/path_to_enlightenment.rs src/koans/the_truth.rs
==> src/path_to_enlightenment.rs <==
koan!("the_truth");

==> src/koans/the_truth.rs <==
#[test]
fn the_truth() {
    assert!(true)
}

cargo run gives me what I expect to see:

$ cargo run
   Compiling koans v0.2.2 (file:///Users/seth/Code/Public/rust-koans)
    Finished dev [unoptimized + debuginfo] target(s) in 0.50s
     Running `target/debug/koans`

running 1 test
test path_to_enlightenment::the_truth ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Ahead of you lies addition.
Eternity lies ahead of us, and behind. Your path is not yet finished.

But immediately running cargo run again, I succeed unexpectedly:

$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
     Running `target/debug/koans`

running 1 test
test path_to_enlightenment::the_truth ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Ahead of you lies boolean.
Eternity lies ahead of us, and behind. Your path is not yet finished.

I note that there's still only one test, and it's for the_truth. What happened to addition? Another cargo run yields both addition and booleans:

$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/koans`
error[E0425]: cannot find value `__` in this scope
 --> src/koans/addition.rs:3:20
  |
3 |     assert_eq!(1 + __, 2)
  |                    ^^ not found in this scope

error[E0425]: cannot find value `__` in this scope
  --> src/koans/boolean.rs:18:24
   |
18 |     assert!("Stuff" == __);
   |                        ^^ not found in this scope

error[E0425]: cannot find value `__` in this scope
  --> src/koans/boolean.rs:25:20
   |
25 |     assert!(num == __);
   |                    ^^ not found in this scope

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0425`.

To learn more, run the command again with --verbose.
Meditate on your approach and return. Mountains are merely mountains.

A fun fact is that I can restore the invalid condition at will:

$ echo 'koan!("the_truth");' > src/path_to_enlightenment.rs
$ cargo run; cargo run
...
Ahead of you lies addition.
Eternity lies ahead of us, and behind. Your path is not yet finished.
...
Ahead of you lies boolean.
Eternity lies ahead of us, and behind. Your path is not yet finished.

And it seems like the path is working like it should:

$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/koans`

running 1 test
test path_to_enlightenment::the_truth ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Ahead of you lies addition.
Eternity lies ahead of us, and behind. Your path is not yet finished.
$ cat src/path_to_enlightenment.rs
koan!("the_truth");
koan!("addition");

What's extra neat about this situation is that it's quite stable until I modify any of the files, either by completing the addition koan or even so much as a touch, which breaks the spell:

$ for i in {1..100}; do cargo test -q > /dev/null; done
$ cargo test -q

running 1 test
test path_to_enlightenment::the_truth ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

$ touch src/main.rs
$ cargo run
   Compiling koans v0.2.2 (file:///Users/seth/Code/Public/rust-koans)
    Finished dev [unoptimized + debuginfo] target(s) in 0.52s
     Running `target/debug/koans`
error[E0425]: cannot find value `__` in this scope
...

I don't know if this is related to #36, but I am running a very recent version of rust:

$ cargo --version
cargo 1.29.0 (524a578d7 2018-08-05)
$ rustc --version
rustc 1.29.0 (aa3ca1994 2018-09-11)

Do you think you could point me in the right direction? This behavior feels like a cargo bug, but I might be missing something obvious. Oh, and I wanted to be sure to say thank you for such a fun intro to the language!

@crazymykl
Copy link
Owner

This is a truly excellent bug report. I'm sorry I didn't have time to look into it when you reported it, but I sure will now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants