Clojure

Primitive return type of loop and try is lost

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: Backlog
  • Fix Version/s: Release 1.9
  • Component/s: None
  • Labels:
    None
  • Environment:
    Clojure commit 9052ca1854b7b6202dba21fe2a45183a4534c501, version 1.3.0-master-SNAPSHOT
  • Patch:
    Code and Test
  • Approval:
    Incomplete

Description

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

Generates the following warnings:

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:

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

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

(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:

(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: CLJ-1422

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

  1. 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti.patch
    28/Aug/15 11:51 AM
    25 kB
    Nicola Mometto
  2. 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti-v2.patch
    28/Aug/15 6:38 PM
    24 kB
    Nicola Mometto
  3. 0002-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti.patch
    19/Jan/16 4:04 PM
    60 kB
    Kevin Downey
  4. hoistedmethod-pass-1.diff
    22/Jul/14 8:39 PM
    22 kB
    Kevin Downey
  5. hoistedmethod-pass-2.diff
    23/Jul/14 12:43 AM
    24 kB
    Kevin Downey
  6. hoistedmethod-pass-3.diff
    25/Jul/14 7:08 PM
    24 kB
    Kevin Downey
  7. hoistedmethod-pass-4.diff
    26/Jul/14 12:52 PM
    29 kB
    Kevin Downey
  8. hoistedmethod-pass-5.diff
    26/Jul/14 12:58 PM
    29 kB
    Kevin Downey
  9. hoistedmethod-pass-6.diff
    25/Aug/15 12:58 PM
    36 kB
    Kevin Downey
  10. hoistedmethod-pass-7.diff
    27/Aug/15 9:20 PM
    52 kB
    Kevin Downey

Activity

Rich Hickey made changes -
Field Original Value New Value
Fix Version/s Release.Next [ 10038 ]
Approval Vetted
Christopher Redinger made changes -
Fix Version/s Approved Backlog [ 10034 ]
Fix Version/s Release.Next [ 10038 ]
Affects Version/s Approved Backlog [ 10034 ]
Affects Version/s Release.Next [ 10038 ]
Rich Hickey made changes -
Fix Version/s Approved Backlog [ 10034 ]
Fix Version/s Release 1.6 [ 10157 ]
Alex Miller made changes -
Affects Version/s Approved Backlog [ 10034 ]
Affects Version/s Backlog [ 10035 ]
Alex Miller made changes -
Fix Version/s Release 1.6 [ 10157 ]
Rich Hickey made changes -
Fix Version/s Release 1.7 [ 10250 ]
Kevin Downey made changes -
Attachment hoistedmethod-pass-1.diff [ 13139 ]
Kevin Downey made changes -
Patch Code [ 10001 ]
Kevin Downey made changes -
Attachment hoistedmethod-pass-2.diff [ 13140 ]
Kevin Downey made changes -
Attachment hoistedmethod-pass-3.diff [ 13147 ]
Kevin Downey made changes -
Attachment hoistedmethod-pass-4.diff [ 13152 ]
Kevin Downey made changes -
Attachment hoistedmethod-pass-5.diff [ 13153 ]
Alex Miller made changes -
Fix Version/s Release 1.7 [ 10250 ]
Fix Version/s Release 1.8 [ 10254 ]
Fogus made changes -
Assignee Fogus [ fogus ]
Fogus made changes -
Assignee Fogus [ fogus ]
Alex Miller made changes -
Approval Vetted [ 10003 ] Incomplete [ 10006 ]
Kevin Downey made changes -
Attachment hoistedmethod-pass-6.diff [ 15009 ]
Alex Miller made changes -
Approval Incomplete [ 10006 ] Vetted [ 10003 ]
Alex Miller made changes -
Approval Vetted [ 10003 ] Incomplete [ 10006 ]
Kevin Downey made changes -
Attachment hoistedmethod-pass-7.diff [ 15019 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti.patch [ 15020 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti.patch [ 15020 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti.patch [ 15021 ]
Nicola Mometto made changes -
Attachment 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti.patch [ 15021 ]
Nicola Mometto made changes -
Alex Miller made changes -
Approval Incomplete [ 10006 ] Vetted [ 10003 ]
Alex Miller made changes -
Description {code}
(set! *warn-on-reflection* true)
(fn [] (loop [b 0] (recur (loop [a 1] a))))
{code}

Generates the following warnings:

{noformat}
recur arg for primitive local: b is not matching primitive, had: Object, needed: long
Auto-boxing loop arg: b
{noformat}

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

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

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

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

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

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

Reported by leafw in IRC: http://clojure-log.n01se.net/date/2011-01-03.html#10:31
{code}
(set! *warn-on-reflection* true)
(fn [] (loop [b 0] (recur (loop [a 1] a))))
{code}

Generates the following warnings:

{noformat}
recur arg for primitive local: b is not matching primitive, had: Object, needed: long
Auto-boxing loop arg: b
{noformat}

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

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

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

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

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

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

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

*Patch:* 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti.patch
Summary Compiler loses 'loop's return type in some cases Primitive return type of loop is lost
Alex Miller made changes -
Patch Code [ 10001 ] Code and Test [ 10002 ]
Nicola Mometto made changes -
Description {code}
(set! *warn-on-reflection* true)
(fn [] (loop [b 0] (recur (loop [a 1] a))))
{code}

Generates the following warnings:

{noformat}
recur arg for primitive local: b is not matching primitive, had: Object, needed: long
Auto-boxing loop arg: b
{noformat}

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

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

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

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

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

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

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

*Patch:* 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti.patch
{code}
(set! *warn-on-reflection* true)
(fn [] (loop [b 0] (recur (loop [a 1] a))))
{code}

Generates the following warnings:

{noformat}
recur arg for primitive local: b is not matching primitive, had: Object, needed: long
Auto-boxing loop arg: b
{noformat}

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

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

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

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

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

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

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

*See Also:* CLJ-1422

*Patch:* 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti.patch
Nicola Mometto made changes -
Summary Primitive return type of loop is lost Primitive return type of loop and try is lost
Nicola Mometto made changes -
Description {code}
(set! *warn-on-reflection* true)
(fn [] (loop [b 0] (recur (loop [a 1] a))))
{code}

Generates the following warnings:

{noformat}
recur arg for primitive local: b is not matching primitive, had: Object, needed: long
Auto-boxing loop arg: b
{noformat}

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

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

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

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

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

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

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

*See Also:* CLJ-1422

*Patch:* 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti.patch
{code}
(set! *warn-on-reflection* true)
(fn [] (loop [b 0] (recur (loop [a 1] a))))
{code}

Generates the following warnings:

{noformat}
recur arg for primitive local: b is not matching primitive, had: Object, needed: long
Auto-boxing loop arg: b
{noformat}

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

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

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

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

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

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

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

*See Also:* CLJ-1422

*Patch:* 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti-v2.patch
Attachment 0001-CLJ-701-add-HoistedMethod-to-the-compiler-for-hoisti-v2.patch [ 15024 ]
Alex Miller made changes -
Approval Vetted [ 10003 ] Incomplete [ 10006 ]
Alex Miller made changes -
Fix Version/s Release 1.8 [ 10254 ]
Fix Version/s Release 1.9 [ 10750 ]
Kevin Downey made changes -

People

  • Assignee:
    Unassigned
    Reporter:
    Chouser
Vote (2)
Watch (7)

Dates

  • Created:
    Updated: