Lexical scope (recently added to emacs) changes the rules, and some documentation is still out of date. The current documentation for setq is this manual page which says
When dynamic variable binding is in effect (the default), set has the
same effect as setq, apart from the fact that set evaluates its symbol
argument whereas setq does not. But when a ...