Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
178c4f8
absvector: reject a length that is not a non-negative integer
Nov 5, 2026
2150aca
compiler: restore all compile state when a compile raises
Nov 5, 2026
3983a3d
variable?: answer false for a non-symbol without throwing
Nov 5, 2026
2de0c34
set, value: raise on a non-symbol instead of keying on tostring()
Nov 5, 2026
1f6d4be
eval-kl: a symbol evaluates to itself, not to its global's value
Nov 5, 2026
90ac712
hash: raise on a bound that is not a positive integer
Nov 5, 2026
6b052ac
close: idempotent, with a Shen error for a closed or non-stream
Nov 5, 2026
9475697
get-time: unix is the Unix time; an unknown option raises
Nov 5, 2026
4adf578
str: a string comes back quoted
Nov 5, 2026
0a1a7a0
fasl: record a global push as a delta, not the whole list
Nov 5, 2026
2369595
reader: native paths for plain tokens by first code
Nov 5, 2026
2d04ad0
macroexpand: shen.walk keeps the old cells until a child changes
Nov 5, 2026
0035a86
address->, <-address: reject an index outside the vector
Nov 5, 2026
7d02f9b
compiler: read hd/tl directly where (cons? E) proves E a cons
Nov 5, 2026
1ce137f
boot: replay the stdlib datatypes from the signature sidecar
Nov 5, 2026
8292a23
typecheck: harvest the kernel signatures at the first typecheck
Nov 5, 2026
b531fc1
boot: default GC stepmul 1000
Nov 5, 2026
aff66fb
prims: a one-argument partial is a closure with no tables
Nov 5, 2026
c6fef07
fasl: a replayed declare skips the variancy query when no old type ex…
Nov 5, 2026
8dbef22
calls through a value: fixed-arity helpers, whole chains, untagged la…
Nov 5, 2026
5d6b380
lambdas: compile a group as one function, build a closed one once
Nov 5, 2026
2e2e90c
defuns bind hot runtime helpers as locals; f-error looked up only if …
Nov 5, 2026
4493903
gc: past a small live heap, aim for a fixed growth rather than pause 400
Nov 5, 2026
9f408aa
count sinking: open the stack count only on paths that make a non-tai…
Nov 5, 2026
7e418d5
tests: run calls_spec with the port specs
Nov 5, 2026
195c152
runtime: reuse finished stack segments
Nov 6, 2026
24d0e36
prolog: no loops on the common deref and unify paths
Nov 6, 2026
d1401d0
prims: address-> stores with rawset
Nov 6, 2026
cc23716
compiler: a loop's accumulator is a double from the start
Nov 6, 2026
7c0a5d9
prims: native shen.mod for exact integers
Nov 6, 2026
3c6974c
Merge team/conform: contract conformance fixes
Nov 6, 2026
5e357ce
Merge team/boot: startup, compile cost, memory
Nov 6, 2026
4ed7eac
Merge team/lists: hd/tl proof and stepmul 1000
Nov 6, 2026
3782f3f
Merge team/calls
Nov 6, 2026
5b4b609
Merge team/prims: Prolog, vectors, strings
Nov 6, 2026
b26ba6f
boot: every codegen switch is in the kernel cache key
Nov 6, 2026
870d216
gc: the adaptive pause stops once the host sets its own
Nov 6, 2026
ab3dbd7
fasl: a hit warns when a datatype rule types (fn F) for a name with n…
Nov 6, 2026
f15a577
tests: (function host-count) raises, as it does at dd24cbb
Nov 6, 2026
9f9a79e
address->: the inline range check takes only vectors
Nov 6, 2026
08c6adf
tests: a test that is not a boolean raises
Nov 6, 2026
79a3273
Merge origin/main (912596b): kernel 43.2, release 0.12.0
Nov 6, 2026
32dbc61
changelog: unreleased section for the team branches
Nov 6, 2026
cffe170
tests: a tail call in the last operand of and/or stays a tail call
Nov 6, 2026
22442ec
tests: and/or tail calls under freeze and lambda bodies; specs at dep…
Nov 6, 2026
9e1da40
CURnP: settle a symbol head before the last argument runs
Nov 6, 2026
e57f3f4
tests: a predicate with too few arguments is not a boolean
Nov 6, 2026
8abcd2a
APP: tell compiled lambdas by the chunks load_chunk loaded
Nov 6, 2026
305c589
segments: keep a yield's values exact, and pool no coroutine with a hook
Nov 6, 2026
d351f08
compiler: a compile that raises leaves no cons facts behind
Nov 6, 2026
0bc76b1
tests: not raises on a non-boolean when compiled
Nov 6, 2026
d1a17e4
certify: fail when a test fails, stops early, or too few run
Nov 6, 2026
cba4b46
ci: require the native typechecker, run the golden corpus, miss no spec
Nov 6, 2026
dfa3335
compiler: a discarded compile leaves no state behind
Nov 6, 2026
9e13a61
tests: a lambda's tail stays a tail call with no enclosing defun
Nov 6, 2026
8633789
embedding: a function value crossing the API takes any number of argu…
Nov 6, 2026
7f767f6
fasl: a set to the value already there still replays
Nov 6, 2026
ed4d4b3
certify: the expected test count belongs to the kernel release
Nov 6, 2026
16fe31f
tests: compiled output against itself, and no undeclared globals
Nov 6, 2026
67a79f3
boot: run on Lua 5.5, where the GC options changed
Nov 6, 2026
b942319
embedding: drop the boundary wrapper for function values
Nov 6, 2026
734e4cb
lambdas: given fewer arguments than they take, return a partial
Nov 6, 2026
cc2a162
changelog: everything since 32dbc61, and the stated limits
Nov 7, 2026
5a0228d
changelog: thaw of a one-parameter lambda, raw over-application, the …
Nov 7, 2026
3c0dc96
Merge remote-tracking branch 'origin/main' into team/all-nil
Nov 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ jobs:

# Tier 2: canonical kernel certification. Always run for real.
- name: Kernel certification (make certify)
run: make certify LUA=luajit
run: SHEN_TYPECHECK_NATIVE=require make certify LUA=luajit

# The native typechecker and Prolog engine against recorded results.
- name: Golden typecheck corpus (make golden)
run: SHEN_TYPECHECK_NATIVE=require make golden LUA=luajit

coverage:
name: Coverage (best-effort)
Expand Down
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,71 @@ Notable changes to shen-lua. Release notes for earlier versions are under

## [Unreleased]

### Changed

- **Startup and compile cost.** `variable?` no longer throws on a non-symbol; the
fasl records a global push as a delta (SHENFASL9), the reader has native paths for
plain tokens, macroexpansion keeps unchanged cells, the stdlib datatypes replay from
the signature sidecar (SHENSIG2), and a replayed `declare` skips the variancy query
when the compile run found no old type. The GC pause adapts past a small live heap
and stops adapting once the host sets its own; the default stepmul is 1000, which
trades work for memory (a string-building loop: +7% instructions, 78 to 47 MB).
- **Calls and closures.** Fixed-arity `APPn`/`CURn` helpers, uncurried lambda groups,
closed lambdas built once, hot helpers bound as locals, count sinking. `(= F G)` can
now be true for two evaluations of the same closed lambda.
- **Lists, vectors, strings, Prolog.** `hd`/`tl` read directly where `(cons? E)`
proves a cons; `address->` stores with `rawset`; a self-tail accumulator is a double
from the start; native `shen.mod` below 2^53; the Prolog engine reuses stack
segments and has loop-free deref and unify.
- **Kernel cache key** covers every codegen switch: `SHEN_UNCURRY`,
`SHEN_HOIST_LAMBDA`, `SHEN_SINK_COUNT` and `SHEN_FREEZE_CONT` as well as `SHEN_TRMC`.
- **Calling a function value from Lua.** A compiled lambda called with fewer arguments
than it takes returns the partial application over the ones it got, wherever the host
got it (`shen.eval`, `shen.value`, a callback argument, an element of a list): `f(1)(2)`
and `f(1, 2)` are the same. It tests its last parameter for nil on entry, since nil is
never a Shen value. **Edge:** a host function that returns nothing (nil) into Shen,
whose result is then passed as a lambda's last argument, gets that lambda's partial
application rather than a call. Through the Lua bridge (`lua.call` and the
marshalers) this cannot happen, since a nil result becomes `()`; only a function
installed directly in `shen.prims.F` could do it. `shen.prims.F[name]`, a defun's own
function, still takes exactly its arity when called raw, as before.
Also deliberate, from the host only: a raw call with too many arguments,
`add(1, 2, 3)` for a two-parameter lambda, ignores the extra and gives 3, where 0.12.0
returned a function.
- **CI and gates.** `make certify` fails when a test fails, the suite stops early or
fewer tests run than the kernel release has (154 for 43.2); it used to exit 0 whatever
happened. CI runs it with `SHEN_TYPECHECK_NATIVE=require`, and runs the new
`make golden` (typechecker and Prolog results, y-combinator inference count). A spec
file missing from `scripts/run-tests.lua` fails the run.
- **Lua 5.5** boots: its collector options changed.

### Fixed (behaviour changes)

- A test that is not a boolean raises: the test of `if` and `cond`, both operands of
`and`/`or`, and the argument of `not`. `(if 1 a b)` used to give `a`, and `(not 5)`
compiled gave `false`. A predicate with too few arguments is not a boolean.
**Limit:** a call in tail position as the last operand of `and`/`or`, in a defun or a
lambda, stays a tail call and is not checked itself; a test of the function's result
is what raises. So `(define f X -> (and true (g X)))` with `g` returning 5 gives
`(f 5)` = 5 unless the caller tests it. shen-go does the same; Shen/JIT and
Shen/Scheme raise.
- `(str "a")` gives `"\"a\""`, quoted, as on the other ports.
- `absvector` rejects a length that is not a non-negative integer; `address->` and
`<-address` reject an index outside the vector; `set`/`value` raise on a non-symbol;
`hash` raises on a bound that is not a positive integer; `close` is idempotent;
`(get-time unix)` is the Unix time; `(eval-kl sym)` gives the symbol.
- `(thaw F)` for a compiled lambda that takes arguments gives a partial application, as
before uncurrying; it no longer runs the body with nil. For a one-parameter lambda that
is the lambda itself; 0.12.0 ran its body with nil.
- A compile that raises, or a compile attempt the compiler throws away, leaves no state
behind for later code. One such case read an undeclared local as nil and returned a
wrong answer with no error (count sinking on a branch compiled twice).
- A host's own Lua function is called as given whatever its chunk is named; a host's
yield through a stack segment keeps its exact values; on PUC Lua a hook set during a
job does not leak into the next.
- A fasl replays a macro's `(set ...)` even when the global already held that value
when the file was compiled.

## [0.12.0] - 2026-11-05

### Changed
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
# LUA selects the interpreter (default: luajit, the project's primary host).
LUA ?= luajit

.PHONY: all test certify test-all coverage help
.PHONY: all test certify golden test-all coverage help

all: test

help:
@echo "make test - run the port-authored spec suite (fast)"
@echo "make certify - run the canonical Shen kernel certification suite"
@echo "make golden - typechecker and Prolog results against the golden corpus (LuaJIT)"
@echo "make test-all - run both tiers"
@echo "make coverage - run luacov over the port specs (best-effort)"

Expand All @@ -29,6 +30,10 @@ test:
certify:
$(LUA) run-kernel-tests.lua

# golden: 27 typecheck and Prolog results, and the y-combinator's inference count.
golden:
$(LUA) bench/golden_typecheck.lua compare

# test-all: both tiers — our specs plus the canonical certification.
test-all: test certify

Expand Down
12 changes: 10 additions & 2 deletions bench/golden_typecheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ ffi.cdef[[int chdir(const char*); char *getcwd(char*, size_t);]]
local cwdbuf = ffi.new("char[4096]")
assert(ffi.C.getcwd(cwdbuf, 4096) ~= nil)
local ROOT = ffi.string(cwdbuf)
assert(ffi.C.chdir("../cl-source/ShenOSKernel-42/tests") == 0,
"tests dir not found (expected ../cl-source/ShenOSKernel-42/tests)")
local TESTS = os.getenv("SHEN_TESTS_DIR") or "tests"
assert(ffi.C.chdir(TESTS) == 0, "tests dir not found: " .. TESTS)

-- same environment fixes typecheck_alloc.lua needs
local mf = P.F["shen.macros"]
Expand Down Expand Up @@ -136,10 +136,13 @@ local GOLDEN = ROOT .. "/" .. (arg[0]:gsub("[^/]*$", "")) .. "golden_typecheck.g
local mode = arg[1] or "compare"

local results = {}
local INFERENCES
for _, entry in ipairs(CORPUS) do
local name, fn = entry[1], entry[2]
local infs0 = P.F["inferences"]()
local ok, res = pcall(fn)
results[name] = ok and serialize(res) or ("#<error: " .. tostring(res) .. ">")
if name == "tc-ycombinator" then INFERENCES = P.F["inferences"]() - infs0 end
end

if mode == "capture" then
Expand Down Expand Up @@ -171,6 +174,11 @@ elseif mode == "compare" then
pass = pass + 1
end
end
-- the kernel's own count for the y-combinator: engines must agree with it too
if INFERENCES ~= 431741 then
fail = fail + 1
io.write("FAIL tc-ycombinator inferences: ", tostring(INFERENCES), ", wanted 431741\n")
end
io.write(string.format("golden compare: %d pass, %d fail\n", pass, fail))
os.exit(fail == 0 and 0 or 1)
else
Expand Down
Loading
Loading