Uploaded image for project: 'Clojure'
  1. CLJ-1422

Recur around try boxes primitives

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects versions: Release 1.6, Release 1.5
    • Fix versions: None

      Description

      Primitive function and recur variables can't pass through a (try) cleanly; they're boxed to Object instead. This causes reflection warnings for fns or loops that use primitive types.

      user=> (set! *warn-on-reflection* true)
      true
       
      user=> (fn [] (loop [t 0] (recur t)))
      #<user$eval676$fn__677 user$eval676$fn__677@3d80023a>
       
      user=> (fn [] (loop [t 0] (recur (try t))))
      NO_SOURCE_FILE:1 recur arg for primitive local: t is not matching primitive, had: Object, needed: long
      Auto-boxing loop arg: t
      #<user$eval680$fn__681 user$eval680$fn__681@5419323a>
      
      user=> (fn [^long x] (recur (try x)))
      NO_SOURCE_FILE:1 recur arg for primitive local: x is not matching primitive, had: Object, needed: long
      
      CompilerException java.lang.IllegalArgumentException:  recur arg for primitive local: x is not matching primitive, had: Object, needed: long, compiling:(NO_SOURCE_PATH:1:1) 
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              aphyr Kyle Kingsbury
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated: