pith is self-hosting and runs real programs, but it is not finished. this page lists what does not work yet, or works with a catch, so you can plan around it. open defects carry their issue number. if something here now works, the page is stale and a fix to it is welcome.
-
a variant pattern must be qualified. write
Color.Red, notRed. a bare name in a pattern is a binding that matches every value, so one that names a variant of the matched enum is rejected (E228).==on enums with payloads compares tags and then payloads, strings by content and nested enums recursively, but a struct payload compares by identity:Box.Holds(P(1)) == Box.Holds(P(1))is false. -
range patterns take non-negative integer literals.
0..=9 => ...and0..10 => ...work on integer subjects, with or-patterns and guards. a negative bound (-5..=-1) and a named constant (LO..=9) do not parse, and aFloatsubject is E228. use a guard instead:n if n < 0 => .... -
if letandwhile letare statements. neither works as an expression, and the let position takes a variant pattern or an optional binding only. a literal (if let 3 = f():) is E245. -
an unannotated
nonetakes its type from the first assignment.mut x := nonefollowed byx = 5makesxanInt?, and a laterx = "s"is rejected. annotate the binding when the first assignment is far from the declaration. -
where a plain value does not widen into an optional.
3is accepted wherever anInt?is expected (bindings, returns, arguments, fields, container stores and literals, variant payloads, generic parameters), with three exceptions:- an arrow-bodied lambda with a declared optional return:
fn(x: Int) -> Int? => xis E200. the block form (fn(x: Int) -> Int?:withreturn x) widens. - ordering operators:
o < 5on anInt?is E217.==and!=do widen;o == 5is true only whenoholds5. - a set element or a map key. see the next entry.
- an arrow-bodied lambda with a declared optional return:
-
set elements and map keys must be ints, strings or bytes.
Set[T]andMap[K, V]hash those three flavors only, and any other element or key type (an optional,Float,Bool, a struct, an enum, a tuple, a container, a function value) is rejected with E254. key by a string, integer or bytes encoding of the value instead. bytes keys hash and compare by content. an optional map value is fine. -
some runtime errors stop the process.
xs[i]andxs[i] = vout of range,m[k]on a missing key and.value()on anoneprintpith runtime error: ...and exit, except inside aT!function, where they propagate as an error. division by zero and integer overflow exit in either case.xs.get(i)andm.get(k)return an optional, andif let,matchandunwrap_orhandle anonewithout stopping.inside an http handler (std.net.http, std.web, the http/2 server) or a grpc method, the same errors fail only that request: the client gets a 500, or grpc status
INTERNAL, the message goes to stderr with the request's method and path, and the server keeps serving. what the failed handler held is not freed and itsdeferblocks do not run, though aMutexit held is unlocked. an error in main or in any other task, a stack overflow and a failed allocation still stop the process. docs/failure_isolation.md has the details. -
a local that shadows a module global takes the name for the whole function. the global is unreachable from that function, except on either side of a
forloop whose variable shadows it. reading the global and then binding a local of the same name in one function is E266.pith lintreports the shadowing as E308. -
same-named types in different modules. two modules can each declare a struct or enum, plain or generic, with the same name, and each value dispatches to its own module's methods. a second impl block that declares a method the struct already has is E263 (an interface impl may repeat an inherent method of the same name, as std/io does).
-
method syntax never reaches a free function. there is no ufcs. a primitive receiver resolves builtins only, so
(1.5).to_int()is theFloatbuiltin even when a freefn to_intexists. -
where clauses attach to functions and methods only. struct, interface and impl headers take inline bounds (
[T: Display]), and a method'swhereclause may name only the method's own type parameters, not the owner's (E264). -
an index into a field of closures can read as type arguments.
t.items[MAX](y), withMAXa screaming-case constant or a type-shaped name, parses as a generic method call, and the checker refuses it with E209. group the index:(t.items[MAX])(y). see docs/generics.md. -
generic enum gaps.
Chain[Int].Link(...)does not work as a constructor; let an annotated binding or the payload supply the instance. a generic function does not inferTfrom aChain[T]argument (head_of(pair)is E222). a payload-free variant bound with no annotation (b := Opt.Nothing) is E262. -
a generic body is checked only at the types the program uses. each specialization is type checked against its concrete types, so a body that is wrong for some type its bound admits is reported only when a caller reaches that type.
pith checknames the specialization (... in bad[String]). -
spawnwith a builtin call in an argument fails to compile (#1082).spawn f(bit_and(x, y))fails withunknown load source. bind the argument to a local first. -
destructor limits. a generic struct cannot implement
Drop(E268), and adropthat letsselfescape leaves a dangling reference rather than being refused. see docs/ownership.md.
- tls 1.2 is a fallback. the client and server speak tls 1.3 and fall back
to 1.2 with ecdhe and aead suites only, refusing anything older.
require_tls13()locks a config to 1.3. the 1.2 path does client certificates but no session resumption or renegotiation. - most resource types close by hand.
std.net.tls.Configis the only std type that implementsDrop. files, processes, connections, listeners, websocket sessions, grpc streams, buffered readers and writers and database handles still needclose();pith lintflags a local one that is never closed (E307). docs/destructors_roadmap.md tracks the rest. - testing has no benchmarks.
pith testrunstestblocks with--filter,--tag,--exclude-tagand--json, andstd/testingadds assertions, fixtures and parameterized cases, but there is no benchmark runner. - json decode targets.
json.decode[T]andjson.decode_text[T]fill a struct whose public fields areInt,String,Bool,Float, optionals of those, nested structs,Lists andMap[String, _]s, nested to any depth. refused with E219: a map with a non-Stringkey, and a list or map whose element is an optional (List[Int?]). reach those documents throughjson.parseand the node accessors. documents nested deeper than 128 levels are refused. - toml, yaml and config decode targets are narrower.
toml.decode,yaml.decodeandconfig.decoderefuseFloat,ListandMapfields (E219). read those through the parsed document instead. - plaintext http/2 needs its own listener.
web.listen_tlsnegotiates h2 or http/1.1 over alpn. without tls there is no negotiation, so plaintext http/2 means callinglisten_h2c.std.net.httpitself is http/1.1. - regex is deliberately small.
std.regexcovers literals,., classes,\d \w \s, greedy* + ?, alternation, capturing groups and^ $. matching is a pike vm, linear in the input. lazy quantifiers and lookaround are compile errors, but counted repeats and backreferences are not:a{2}matches the literal texta{2}and(a)\1matchesa1. matching works on bytes, so.consumes one byte, not one character; a match never ends inside a multi-byte character. - gzip compresses with fixed huffman codes only. it reads any deflate stream and writes valid gzip and zlib, but without dynamic huffman trees the output is a few percent larger than it could be.
os.set_envdoes not reach c code.os.set_envandos.unset_envwrite an overlay the runtime owns instead of calling libc'ssetenv, which is unsafe once threads exist. pith reads (env.get,os.get_env) and spawned children see the overlay, but c code inside the process does not:RES_OPTIONSset from pith never reaches the resolver. set such variables in the environment the process starts with.metrics.reset()orphans live instruments. an instrument taken before a reset keeps writing to a series nothing scrapes. take a fresh one after.- the tls root bundle cache holds eight bundles. a process that trusts more than eight distinct ca bundles keeps working but re-parses the ones past the cap on every config, and a cached bundle is never evicted.
- the language server caches one import closure. an edit to the open document re-checks that document alone, but an edit to an imported module re-checks the whole closure, and switching between two open documents misses the cache on each switch. references on a common name in a large closure can fail to answer (#1071). see docs/lsp.md.
- a declaration or a statement points at its last token. an expression, type or pattern diagnostic points at where it starts, but one about a function or a statement names the line of its last token: a duplicate method is reported on the last line of its body. go-to-definition on a local lands on the end of its initializer (#1158).
- no package registry. dependencies are local path entries in
pith.toml.pith package lockandpith package installwork on those paths, but nothing fetches over the network. - no debugger. a runtime error prints its message without a stack trace, and there is no stepping.
- an unmarked strong reference cycle leaks. reclamation is reference
counting, so a cycle with no
weakedge is never freed. break it with aweakfield, aweak name := exprlocal, or a closure that captures a weak binding (docs/ownership.md).pith lintreports a strong cycle between a module's structs as E306. an experimental cycle collector runs behindPITH_CYCLE_GC=1, off by default, withstd.concurrent.gc_collect()to force a pass. - closing a channel can race a send. a send that passes its closed check as another task closes the channel can enqueue a value nobody reads, and the send reports success. a channel costs about 416 bytes plus 16 bytes per buffered slot (rounded up to a power of two) for as long as it lives.
- the green backend is the default on linux only. spawned tasks run on an
m:n green scheduler with an epoll reactor.
PITH_GREEN=0switches to one os thread per task. macos and the bsds default to os threads because there is no kqueue reactor yet;PITH_GREEN=1opts in there, but a green task waiting on a socket blocks its whole worker. - a call with no yield point holds its worker. sockets, dns, file reads
and writes, child processes and sleeps all park the task. the cheap
filesystem calls (
exists,size,rename,mkdir, removing one file) run on the worker, so on a slow network mount they hold every task on it until they return. a file call from inside a task pays a thread handoff that a call frommaindoes not. - a green task's stack does not grow. it is 1 MiB unless
PITH_GREEN_STACK_KBsets another size, and recursion that needs more stops the process with a stack overflow report. - preemption costs a check per loop back-edge. compute-bound tasks are
preempted at safe-points so a spinning loop cannot starve the tasks that
share its worker. building with
PITH_GREEN_PREEMPT=0removes the check, and with it the guarantee. the preemption request flag is process-global, so every running task takes a slow path when any one task overruns (#1089). - a blocked pipe read under
PITH_GREEN=0ignores a close. closing a child's pipe from another task fails every later call on the handle, but a read already blocked in the kernel returns only when the child writes or exits. the green backend wakes it at once.