Document the "no method named `system` found for fn" error
Getting the wrong signature for a function leads to a complex error message like
error[E0599]: no method named `system` found for fn item `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut bevy::prelude::Commands, &'s mut bevy::prelude::ResMut<'t0, GameState>, bevy::prelude::Query<'t1, (&'t2 PieceIndex, &'t3 mut Position), bevy::prelude::With<CurrentPiece>>) {place_current_piece}` in the current scope
--> src/main.rs:168:41
|
168 | .add_system(place_current_piece.system())
| ^^^^^^ method not found in `for<'r, 's, 't0, 't1, 't2, 't3> fn(&'r mut bevy::prelude::Commands, &'s mut bevy::prelude::ResMut<'t0, GameState>, bevy::prelude::Query<'t1, (&'t2 PieceIndex, &'t3 mut Position), bevy::prelude::With<CurrentPiece>>) {place_current_piece}`
|
= note: `place_current_piece` is a function, perhaps you wish to call it
I managed to solve my issue thanks to this reddit comment (specifically I had the arg state: &mut ResMut<GameState> where bevy wanted mut state: ResMut<GameState>), but that was literally the only helpful documentation I could find.
The error and a set of guidelines for what an acceptable fn signature is should be documented somewhere in the bevy book, perhaps in the Troubleshooting section to begin with.
This was one of the issues I ran into when learning Bevy, and it's one of the ones that hasn't gone away. I'm better at diagnosing these issues, but it's too easy to accidentally leave off or add a & or mut, and spotting the problem always feels like finding a needle in a haystack. I'm porting my code to "pre-0.5" now and it's just the same thing over again with new rules.
Documentation is a good short term fix, but I would suggest looking for technical ways to improve the error message here.