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

nth function produces different results from clojure when using a negative index on a sequence

Description

(nth (range 2) -2) produces an out-of-bounds error for clojure; for clojurescript it returns -2
(nth (seq [3 4] -2)) produces an out-of-bounds error for clojure; for clojurescript it returns nil
I expected these to fail.

I think that the clojurescript check (src/main/cljs/cljs/core.cljs line ~1763 "(not (number? n))" is not sufficient,
it could also check for non-negative.

Environment

Mac OS X 10.9.5
lein 2.7.1
lein-cljsbuild 1.1.4
lein-figwheel 0.5.10
v8 5.1.281.47
Chrome Version 58.0.3029.110 (64-bit)
Java 1.8.0_73
"rlwrap lein figwheel"
also demonstrable on online cljs repls:
http://app.klipse.tech/
http://clojurescript.io/
http://clojurescript.net/
which produce a different result than an online clojure repl, e.g.: http://www.tryclj.com/ or "lein repl"

Status

Assignee

David Nolen

Reporter

Mike Wright

Labels

None

Approval

Accepted

Patch

Code and Test

Fix versions

Affects versions

1.9.293

Priority

Minor