Range meta call has constructor args swapped

Description

Per https://ask.clojure.org/index.php/12148/strange-behavior-with-range-and-with-meta

In Range.java, the with-meta method calls the Range constructor with

(meta, end, start, step, boundsCheck, _chunk, _chunkNext)

but the Range constructor takes

(meta, start, end, step, boundsCheck, _chunk, _chunkNext)

This is just a simple bug introduced when this code was added in Clojure 1.7.

Approach:

Swap the start/end to match.

Patch: clj-2721.patch

screened by: fogus

Environment

None

Attachments

1
  • 06 Sep 2022, 02:20 PM

Activity

Show:

Alex MillerDecember 7, 2022 at 9:54 PM

Applied for next 1.12 alpha

Alex MillerOctober 12, 2022 at 6:10 PM

(range 0 5 1.0) ;=> (0 1.0 2.0 3.0 4.0) (with-meta (range 0 5 1.0) {}) ;=> (5) user=> (def x (range 0 5 1.0)) #'user/x user=> x (0 1.0 2.0 3.0 4.0) user=> (with-meta x {}) (5 1.0 2.0 3.0 4.0)

Example for quick verification

Michael FogusSeptember 6, 2022 at 2:48 PM

Understood code and tests. Applied and tested. Additional REPL tests.

Fixed

Details

Assignee

Reporter

Approval

Ok

Patch

Code and Test

Priority

Affects versions

Fix versions

Created September 6, 2022 at 1:40 PM
Updated December 7, 2022 at 9:54 PM
Resolved December 7, 2022 at 9:54 PM

Flag notifications