tools.analyzer

emit-form missing some metadata, leading to reflection warnings when eval'd?

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

I will keep investigating to see if this problem exists only in Eastwood's use of tools.analyzer(.jvm), but here are the symptoms. Use 'lein new reflection' to create a new Leiningen project, and edit the file src/reflection/core.clj to contain:

(ns reflection.core)

(set! *warn-on-reflection* true)

(defn foo [s]
  (doseq [i s]
    (println i)))

Using Eastwood 0.1.0, 'lein eastwood' gives me a reflection warning like the one below, but only about half the time that I run it. The other half of the time there is no reflection warning.

Reflection warning, reflection/core.clj:1:218 - call to nth can't be resolved.

Activity

Hide
Nicola Mometto added a comment -

Fixed with: https://github.com/clojure/tools.analyzer.jvm/commit/7de63ad3f81ed5a60ba0b3031383d1d63db2b51f

Still need to understand if the non-deterministic behaviour of this bug is relevant.

Show
Nicola Mometto added a comment - Fixed with: https://github.com/clojure/tools.analyzer.jvm/commit/7de63ad3f81ed5a60ba0b3031383d1d63db2b51f Still need to understand if the non-deterministic behaviour of this bug is relevant.
Hide
Andy Fingerhut added a comment -

Perhaps your later commits to tools.analyzer(.jvm) indicate areas of potential nondeterminism that you were trying to make deterministic?

Later testing did reveal that in the cases I was getting the reflection warnings, the tag was of type java.lang.Class, and when the tag was of type clojure.lang.Symbol there was no reflection warning. This is consistent with Compiler.java's tagOf() method ignoring any tags except those with class clojure.lang.Symbol or java.lang.String.

I did not determine why the results were nondeterministic.

Show
Andy Fingerhut added a comment - Perhaps your later commits to tools.analyzer(.jvm) indicate areas of potential nondeterminism that you were trying to make deterministic? Later testing did reveal that in the cases I was getting the reflection warnings, the tag was of type java.lang.Class, and when the tag was of type clojure.lang.Symbol there was no reflection warning. This is consistent with Compiler.java's tagOf() method ignoring any tags except those with class clojure.lang.Symbol or java.lang.String. I did not determine why the results were nondeterministic.
Hide
Nicola Mometto added a comment -

No, my later commits are solely for performance enhancements, I was not able to reproduce the nondeterministic results at the repl unfortunately, so I'm unable to figure that out.

Show
Nicola Mometto added a comment - No, my later commits are solely for performance enhancements, I was not able to reproduce the nondeterministic results at the repl unfortunately, so I'm unable to figure that out.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: