We're updating the issue view to help you get more done. 

Primitive return type of loop and try is lost

Description

1 2 (set! *warn-on-reflection* true) (fn [] (loop [b 0] (recur (loop [a 1] a))))

Generates the following warnings:

1 2 recur arg for primitive local: b is not matching primitive, had: Object, needed: long Auto-boxing loop arg: b

This is interesting for several reasons. For one, if the arg to recur is a let form, there is no warning:

1 (fn [] (loop [b 0] (recur (let [a 1] a))))

Also, the compiler appears to understand the return type of loop forms just fine:

1 2 3 (use '[clojure.contrib.repl-utils :only [expression-info]]) (expression-info '(loop [a 1] a)) ;=> {:class long, :primitive? true}

The problem can of course be worked around using an explicit cast on the loop form:

1 (fn [] (loop [b 0] (recur (long (loop [a 1] a)))))

Reported by leafw in IRC: http://clojure-log.n01se.net/date/2011-01-03.html#10:31

See Also:

Patch: 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti-v2.patch

Environment

Clojure commit 9052ca1854b7b6202dba21fe2a45183a4534c501, version 1.3.0-master-SNAPSHOT

Status

Assignee

Unassigned

Reporter

chouser

Labels

None

Approval

Incomplete

Patch

Code and Test

Fix versions

Affects versions

Backlog

Priority

Major