google / google/closure-compiler

Fix unit tests to not have undeclared variables

Open
#2,784 4 comments 0 reactions 1 assignee Claimed by @shicks View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

It would be good to be able to assume that `scope.getVar(name)` will always return non-`null` if `name` comes from a NAME node in `scope`'s AST.

This is already the case in normal compile jobs, since `VarCheck` adds any necessary externs before type checking and other passes run. But this is not the case in unit tests, most of which do not run `VarCheck`. For now we need to add special logic in various places to handle the possibility of null vars, which only ends up being exercised in tests, and this is unfortunate.

To find all the offending tests, just edit `CompilerTestCase` to run `new VarCheck(compiler, false).process(...)` before running `CheckTypes` - there are currently a few hundred failures which must be fixed before this special logic can be removed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.