It's not magic in how it works, it's just magic in it's syntax. It's a variable you don't have to declare. It's ripe for abuse / mistakes and would be one of the things I'd have lints for and watch closely in PRs.
Nim has the same result variable[1] and I absolutely love it.
It helps avoid the classic "oh, I forgot to return it" bug. Also makes the code more succinct and saves you from having to type an extra line for explicit return.
I kind of get why you would be wary of it, as it is a special variable but compared to other messed up stuff like for example Rust treating a line without semicolon as implicit return, it is a relatively tame solution for this problem and can be easily figured out.
Did you ever had any actual bugs caused by the use of result?
If you forgot to return a value, a function shouldn't have compiled. In Nim you can easily forget to return something or have a hole in your branching and get a defaulted value, instead of a compiler error.
In some cases an implicitly declared variable feels neat and convenient, but I'm not sure it's worth it.
Ha, I'm quite used to Rust's last-expression-is-the-value and I also get why some would think it's weird but I find it actually works quite well in practice. Each language has its gymnastics and special moves, I guess. Back to Pascal, I'm not opposed to Result usage per se and I understand the appeal since it's what I grew on. My concerns are more about code maintenance in long-ish functions - I don't have a particular example of mis-usage, but I'd be wary of late reassignments overriding a previously set value. Separating exit points from return value assignment could let code become hard to follow and create situations where it's easy to misread the actual outcome.
It helps avoid the classic "oh, I forgot to return it" bug. Also makes the code more succinct and saves you from having to type an extra line for explicit return.
I kind of get why you would be wary of it, as it is a special variable but compared to other messed up stuff like for example Rust treating a line without semicolon as implicit return, it is a relatively tame solution for this problem and can be easily figured out.
Did you ever had any actual bugs caused by the use of result?
[1] https://nim-by-example.github.io/variables/result/