Bad code gen for `((not empty?) "foo")` when compiled with no optimizations

Description

Using a ClojureScript (1.9.946) REPL If I run:

[(true? ((comp not empty?) "foo")) (false? ((comp not empty?) "")) (true? ((not empty?) "foo")) (false? ((not empty?) ""))]

I get the result: [true true true true]

I would have expected this code to raise an exception. The first two expressions are valid, however the last two expressions don't use comp and just apply not to empty?, which returns false

Interestingly if I run this code in a Clojure (not a ClojureScript) REPL, I get an error that I would expect:

java.lang.Boolean cannot be cast to clojure.lang.IFn

If I compile this code with the ClojureScript compiler using advanced optimizations then I get a runtime error,
which is more like what I would expect:

Uncaught TypeError: b.call is not a function

So when compiled under non-optimization, ((not empty?) "foo") seems to produce unexpected results.

Environment

macOS Sierra (10.12.6).
ClojureScript 1.9.946

Attachments

1
  • 18 Jul 2018, 01:44 PM

Activity

Show:

Mike Fikes July 18, 2018 at 4:01 PM

Just to be extra sure, I ran this patch through Coal Mine (which uses :optimizations :none), and it passed

Ran 47695 tests containing 184114 assertions. 0 failures, 0 errors.

Mike Fikes July 18, 2018 at 1:44 PM

Note: Even though CLJS-2832.patch has tests, we are currently really relying on the self-host tests for automated verification (because they pass regardless in :advanced mode without the patch).

Completed

Details

Assignee

Reporter

Approval

Accepted

Patch

Code and Test

Affects versions

Priority

Created July 18, 2018 at 12:59 PM
Updated August 3, 2018 at 7:58 PM
Resolved August 3, 2018 at 7:58 PM