Redeclaring a name is found while the engine collects declarations, before any line runs. Write firstRedeclaration(declarations) that plays that part of the engine for one scope.
Each declaration is { kind, name }, where kind is "var", "function", "let", "const" or "class". Walk them in order and return the name of the first declaration that would be a SyntaxError, or null if the scope is fine.
var and function may repeat each other freelylet, const and class clash with any earlier declaration of the same name, and any later declaration clashes with them