One practical note for anyone following a tutorial and hitting this: check what version the tutorial was written against before doing anything else.
Board packages update silently in the background, so a fresh install today is not the environment the tutorial's author had. The mismatch is not visible anywhere on the page.
When a copied example fails to compile in a way that looks impossible, the version of the package is the first thing to check, and it is right there in the boards manager.