Phase 11: Fix pre-existing failures — 316/317 passing
- types.janet: ns? now accepts both structs and tables
(defensive for namespace-like tables created via @{...})
- core.janet: wire comment macro into core-bindings
(was in core-macro-names but missing from core-bindings)
- sci/lang_stubs.clj: minimal SCI type stubs for bootstrap
(IBox, HasName, IVar, DynVar protocols, SciUnbound/Var/Namespace deftypes)
- test-load-sci.janet: load stubs before SCI source files,
removed broken preprocessor
Before: 315 ok, 2 fail (SciVar + array/buffer)
After: 316 ok, 1 fail (only deftype in lang.cljc remains)
The remaining failure is lang.cljc's SciVar deftype with #?@ inserts
for JVM/CLJS-specific protocol implementations — a known limitation
for Phase 15 (SCI bootstrap).
This commit is contained in:
parent
1c1100e2f0
commit
09b4e3e1bd
10 changed files with 179 additions and 69 deletions
|
|
@ -54,15 +54,14 @@ A bare expression in the last position of `cond` is treated as a **test** clause
|
|||
|
||||
Without `true`, the last expression executes as a side-effect test between branches. Hit us in buffer-based write-value — raw tuple addresses leaked into REPL output.
|
||||
|
||||
## Janet `cond` Requires `true` Guard for Catch-All
|
||||
## REPL: Buffer-Based Output Prevents C-Runtime Interleaving
|
||||
|
||||
A bare expression in the last position of `cond` is treated as a **test** clause (not body). It executes between other branches as a side-effect test. Use `true` as the test to make it a proper catch-all:
|
||||
Janet's C runtime in `jpm build` executables interleaves native `<tuple 0x...>` output between `prin` statements. Solution: build entire output string in a buffer, then output atomically with a single `print` call. Use `write-value/v buf` + `print-value` creates buffer → `print (string buf)`.
|
||||
|
||||
```janet
|
||||
(cond
|
||||
(nil? x) (buf "nil")
|
||||
(number? x) (buf (string x))
|
||||
true (buf (string x))) ; ← `true` required
|
||||
```
|
||||
## Janet `struct?` Returns `true` for Tuples
|
||||
|
||||
Without `true`, `(push-str buf (string v))` in the last position leaked raw tuple addresses into REPL output.
|
||||
Always check `(tuple? x)` BEFORE `(struct? x)` in cond forms. Otherwise `(get tuple :key)` fails with "expected integer key for tuple in range [0, N), got :key". Hit us in `print-value` (symbol check on tuples) and `eval-form` struct handling.
|
||||
|
||||
## PHM Internal Key Leakage
|
||||
|
||||
PHM and set internal keys (`:jolt/deftype`, `:cnt`, `:buckets`, `:_meta`, `:jolt/type`, `:phm`) leak into `pairs`/`keys` iteration. Core fns that iterate collections (`core-merge`, `core-reduce`, `core-every?`, `core-filter`) must check for `set?`/`phm?` first and use type-aware helpers (`phm-to-struct`, `phs-seq`, `phm-keys`, `phm-entries`) before generic iteration.
|
||||
Loading…
Add table
Add a link
Reference in a new issue