Host interop fixes: ==/time/subvec/defonce + corpus cleanup
- == 1-arg returns true for any value (Clojure short-circuits before the number check), not 'requires numbers'. - current-time-ms wired to now-millis so the time macro works. - subvec truncates float/ratio indices via long (Scheme quotient rejects flonums). - defonce checks bound? not var-get — in a top-level do the name is already an unbound interned cell, which var-get throws on. - drop the line-seq corpus row (used janet/spit, N/A); allowlist char-array (needs Class/forName "[C"). Corpus 2678->2683, floor raised. Re-minted. Full gate green; CI green. jolt-cf1q.7
This commit is contained in:
parent
dd0e0b55cc
commit
cf0b544baf
7 changed files with 23 additions and 13 deletions
|
|
@ -27,12 +27,12 @@
|
|||
([v start end]
|
||||
(when (not (vector? v)) (throw (str "subvec requires a vector")))
|
||||
;; Clojure coerces indices with (int ...): NaN -> 0, floats/ratios truncate
|
||||
;; toward zero ((quot x 1)); non-numbers throw. Only then range-check.
|
||||
;; toward zero; non-numbers throw. Only then range-check.
|
||||
(let [coerce (fn [x]
|
||||
(cond
|
||||
(not (number? x)) (throw (str "subvec index must be a number"))
|
||||
(not= x x) 0
|
||||
:else (quot x 1)))
|
||||
:else (long x)))
|
||||
s (coerce start)
|
||||
e (coerce end)]
|
||||
(when (or (< s 0) (< e s) (< (count v) e))
|
||||
|
|
|
|||
|
|
@ -122,8 +122,11 @@
|
|||
`(bound-fn* (fn ~@fntail)))
|
||||
|
||||
(defmacro defonce [name expr]
|
||||
;; only def when the var has no root value. In a top-level (do ...) the name is
|
||||
;; already interned (an unbound cell) by the time this runs, so check bound? —
|
||||
;; var-get would throw on the unbound cell.
|
||||
`(let [v# (resolve (quote ~name))]
|
||||
(if (and v# (some? (var-get v#)))
|
||||
(if (and v# (bound? v#))
|
||||
v#
|
||||
(def ~name ~expr))))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue