Clojure

Oddity in type tag usage for primInvoke

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Completed
  • Affects Version/s: Release 1.6
  • Fix Version/s: Release 1.8
  • Component/s: None
  • Labels:
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

Some odd behavior demonstrated in Clojure 1.6.0 REPL below. Why does the (Math/abs (f2 -3)) call issue a reflection warning? It seems like perhaps it should not, given the other examples.

user=> (clojure-version)
"1.6.0"
user=> (set! *warn-on-reflection* true)
true
user=> (defn ^{:tag 'long} f1 [x] (inc x))
#'user/f1
user=> (Math/abs (f1 -3))
2
user=> (defn ^{:tag 'long} f2 [^long x] (inc x))
#'user/f2
user=> (Math/abs (f2 -3))
Reflection warning, NO_SOURCE_PATH:6:1 - call to static method abs on java.lang.Math can't be resolved (argument types: java.lang.Object).
2
user=> (defn ^{:tag 'long} f3 ^long [^long x] (inc x))
#'user/f3
user=> (Math/abs (f3 -3))
2

Cause: invokePrim path does not take into account var or form meta

Approach: apply var and form meta to invokePrim expression

Patch: clj-1533-2.patch

Screened by: Alex Miller

Activity

Hide
Nicola Mometto added a comment -
Show
Nicola Mometto added a comment - The issue is similar to http://dev.clojure.org/jira/browse/CLJ-1491
Hide
Nicola Mometto added a comment -

The root cause was also almost the same, the proposed patch is a superset of the one proposed for CLJ-1491

Show
Nicola Mometto added a comment - The root cause was also almost the same, the proposed patch is a superset of the one proposed for CLJ-1491
Hide
Alex Miller added a comment -

Can we include 1491 cases in this ticket and mark 1491 a duplicate?

Show
Alex Miller added a comment - Can we include 1491 cases in this ticket and mark 1491 a duplicate?
Hide
Alex Miller added a comment -

Also needs tests in the patch.

Show
Alex Miller added a comment - Also needs tests in the patch.
Hide
Nicola Mometto added a comment -

Updated the patch with testcases for both issues, I agree that CLJ-1491 should be closed as duplicate

Show
Nicola Mometto added a comment - Updated the patch with testcases for both issues, I agree that CLJ-1491 should be closed as duplicate
Hide
Alex Miller added a comment -

New patch is identical, just refreshed to apply to master

Show
Alex Miller added a comment - New patch is identical, just refreshed to apply to master

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: