Add structured coroutines and explicit error handling

This commit is contained in:
pavel 2026-08-27 16:26:40 +02:00
commit fe62e81152
31 changed files with 1701 additions and 325 deletions

View file

@ -92,7 +92,7 @@ fun main() {
t.Fatalf("unexpected builtin diagnostic: %+v", diagnostic)
}
}
for _, name := range []string{"ByteSlice", "append", "len", "sql", "set", "now"} {
for _, name := range []string{"ByteSlice", "append", "keys", "goAssert", "len", "sql", "set", "now"} {
if !isBuiltin(name) {
t.Fatalf("%s is not registered as builtin", name)
}
@ -694,7 +694,7 @@ fun runWorker(name: String) {
}
fun main() {
go runWorker("alice")
runBlocking { launch { runWorker("alice") } }
}
`)
@ -717,9 +717,11 @@ fun writer(ch: Channel<Int>) {
fun main() {
val ch = Channel<Int>()
go writer(ch)
select {
ch -> println(it)
runBlocking {
launch { writer(ch) }
select {
ch -> println(it)
}
}
val v = ch.read()
println(v)
@ -778,22 +780,11 @@ fun main() {
`)
state := buildDocumentState(text)
if state.program == nil {
t.Fatal("expected parsed program")
if state.program != nil {
t.Fatal("worker syntax should no longer parse")
}
if len(state.diagnostics) != 0 {
t.Fatalf("expected no diagnostics, got %+v", state.diagnostics)
}
var counterDetail string
for _, sym := range state.symbols {
if sym.Kind == symbolKindVariable && sym.Name == "counter" {
counterDetail = sym.Detail
break
}
}
if counterDetail != "val counter: Counter" {
t.Fatalf("unexpected counter detail: %q", counterDetail)
if len(state.diagnostics) == 0 {
t.Fatal("expected removed worker syntax diagnostic")
}
}