print-str, print-i64, print-f64, print-bytes, print-line and newline leave the prelude. print and println are the whole printing surface now, and print is the better call at every one of the sites that used them: it is the same structural walk without the newline, so the no-newline case the family was kept for is covered, and it takes the value as it is. The old print-i64 forced an explicit (i64 x) at every call site, because this language widens nothing implicitly; that cast is gone from 127 places. Dropping it moves one answer. hash-grid returns u64, and the cast through the signed printer showed sand-headless's hash as -2851001042534928384. print routes a u64 through flan_u64_to_bytes, so it now prints 15595743031174623232 — the same 64 bits, read as the unsigned number they are. The pinned expectation follows the correction. test-flan-dev.el and test_session.ml both reached for print-line as "a name the prelude has"; they reach for rand-seed instead.
28 lines
1.0 KiB
Plaintext
28 lines
1.0 KiB
Plaintext
;;;; Comparing enums, which type checked and then died in the backend.
|
|
;;;;
|
|
;;;; Types.is_comparable admits an enum, so the checker was stating an intent
|
|
;;;; emit never honoured: (= k :a) passed check and then raised
|
|
;;;; Failure("comparison on K") with no source location. An enum is an i32 at
|
|
;;;; run time, so all six operators lower to icmp.
|
|
(defenum K [lo -1 mid 0 hi 1])
|
|
|
|
(defstruct S [k K])
|
|
|
|
(defn eq? [k K] bool (= k :mid))
|
|
(defn below? [k K] bool (< k :mid))
|
|
|
|
(defn main [] i32
|
|
;; Equality, both ways round.
|
|
(println (if (eq? :mid) "eq yes" "eq no"))
|
|
(println (if (eq? :hi) "eq yes" "eq no"))
|
|
|
|
;; Ordering, and signed: lo is -1, so an unsigned compare would call it the
|
|
;; largest member and answer the other way.
|
|
(println (if (below? :lo) "lo below mid" "lo not below mid"))
|
|
(println (if (below? :hi) "hi below mid" "hi not below mid"))
|
|
|
|
;; And through a struct field, which is a different path to the same compare.
|
|
(let [s (S {:k :hi})]
|
|
(println (if (= (.k s) :hi) "field eq yes" "field eq no")))
|
|
0)
|