Checked narrow casts; fix runtime require in self-contained-built binaries
byte/short/int/long/char silently wrapped or passed out-of-range values through; the JVM range-checks (RT.byteCast family). One checked-cast helper now carries the ranges: a double range-checks ITSELF before truncating ((byte 1.1) is 1, (byte 127.000001) throws), NaN casts to 0, ratios and bigdecs truncate, a non-number is CCE, and the throw carries the JVM message. float range-checks against Float/MAX_VALUE. The unchecked-* casts now genuinely wrap and sign-fold ((unchecked-byte 200) is -56 — the old bit-and lost the sign) with doubles saturating like Java's conversions; unchecked-long/int are host natives. double/float of a bigdec convert instead of crashing. The no-single-float residue stays accepted (SPEC.md). Also fixes #290: a binary built by the SELF-CONTAINED joltc died with 'variable var-deref is not bound' when a namespace loaded at runtime. The in-process build compiled flat.ss against a clean copy-environment, which orphans every top-level define in locations the binary's runtime eval can't see. It now compiles against the default interaction environment (defines land in the real symbol cells, same as the legacy fresh-Chez path) and a generated prologue pre-binds each kernel name the runtime redefines to its kernel value, so the earliest boot reads match the legacy path's primitive references. requiring-resolve is implemented (the issue's dynamic-require pattern), and the release workflow smokes a runtime require in a built binary. Cast namespaces byte/short/int/long/char now fully clean; cts baseline 5805 -> 5857 pass, 67 baselined namespaces. 7 JVM-certified corpus rows.
This commit is contained in:
parent
f80f9aab4b
commit
d0e1a11934
10 changed files with 237 additions and 77 deletions
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
|
|
@ -109,6 +109,24 @@ jobs:
|
|||
out="$("$work/app/app")"
|
||||
test "$out" = "built: 45" || { echo "self-contained build ran '$out', want 'built: 45'"; exit 1; }
|
||||
|
||||
# A built binary must also run the DYNAMIC require path: a namespace not
|
||||
# in the static ns graph compiles from the source roots at runtime, so the
|
||||
# boot's top-level defines must be visible to the runtime compiler's eval
|
||||
# (issue #290: this died with "variable var-deref is not bound").
|
||||
- name: Smoke a runtime require in a built binary
|
||||
run: |
|
||||
joltc="$(pwd)/target/release/joltc"
|
||||
work="$(mktemp -d)"
|
||||
mkdir -p "$work/app/src/app"
|
||||
printf '{:paths ["src"]}\n' > "$work/app/deps.edn"
|
||||
printf '(ns app.extra)\n(defn greet [s] (str "Hello, " s "!"))\n' \
|
||||
> "$work/app/src/app/extra.clj"
|
||||
printf '(ns app.core)\n(defn -main [& _]\n (println ((requiring-resolve (quote app.extra/greet)) "runtime")))\n' \
|
||||
> "$work/app/src/app/core.clj"
|
||||
( cd "$work/app" && "$joltc" build -m app.core -o app )
|
||||
out="$(cd "$work/app" && ./app)"
|
||||
test "$out" = "Hello, runtime!" || { echo "runtime require ran '$out', want 'Hello, runtime!'"; exit 1; }
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
ver="${GITHUB_REF_NAME}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue