We're updating the issue view to help you get more done. 

User supplied type hints stopped working on js/goog.DEBUG which means DCE can fail

Description

Somewhere between version 1.9.293 and 1.9.456 the type hint "^boolean" stopped working for "js/goog.DEBUG" and, as a result, this expression silently stopped being a functioning DCE guard in ":advanced" compilations.

So this code example no longer "works" (in the sense that DCE doesn't happen anymore):

1 2 (when ^boolean js/goog.DEBUG ... some dev-time code in here which we want to Dead Code Eliminate at prod-time)

Note: if the guard condition is changed to use "^boolean goog.DEBUG" (no leading "js/") then it does work. So the leading "js/" is a problem.

thheller speculates that this bug arose during the introduction of :infer-externs
https://github.com/clojure/clojurescript/commit/0560106fe8576fd7029d86e61be09cd1f246bfe0

Some discussion in slack:
https://clojurians-log.clojureverse.org/cljs-dev/2017-05-04.html

I have created a minimal repo which demonstrates the problem:
https://github.com/mike-thompson-day8/CLJS-issue-2023

Environment

None

Status

Assignee

David Nolen

Reporter

Mike Thompson

Labels

None

Approval

None

Patch

Code and Test

Fix versions

Priority

Minor