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):

(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

Attachments

1
  • 15 May 2017, 02:13 AM

Activity

Show:

António Monteiro May 15, 2017 at 2:13 AM

Attached patch with fix and test.

Thomas Heller May 7, 2017 at 1:08 PM

This can be reproduced by running cljs.analyzer.api/analyze on (with-meta 'js/goog.DEBUG {:tag 'boolean}).

{:form ^boolean js/goog.DEBUG, :op :var, :info {:name ^boolean js/goog.DEBUG, :ns js, :tag ^{:prefix [goog DEBUG]} js}, :tag ^{:prefix [goog DEBUG]} js}

Running a quick git bisect the :tag changed from boolean to js in this commit:
https://github.com/clojure/clojurescript/commit/0560106fe8576fd7029d86e61be09cd1f246bfe0

Completed

Details

Assignee

Reporter

Patch

Fix versions

Priority

Created May 7, 2017 at 12:34 PM
Updated May 15, 2017 at 1:27 PM
Resolved May 15, 2017 at 1:27 PM