Using SQL Prompt v188.8.131.5227, try formatting this and you'll see that Format drops the reference #my_tb on the JOIN clause, leaving the column as ambiguous and thereby fails SQL parsing:
CREATE TABLE #my_tb (database_id int)
INSERT INTO #my_tb VALUES (1), (2), (3), (4)
JOIN sys.databases db ON db.database_id = #my_tb.database_id
The work-around is to provide an alias for #my_tb, but that shouldn't be necessary.