Inject ambient context into Go calls

This commit is contained in:
pavel 2026-08-27 22:31:10 +02:00
commit 5085ae51aa
8 changed files with 112 additions and 9 deletions

View file

@ -1217,6 +1217,12 @@ func (g *goGenerator) expr(expr Expr, expectedType string) (string, error) {
}
args = append([]string{g.currentCoroutineScope}, args...)
}
if call, ok := resolvedCall.Node.(HIRGoCall); ok && call.InjectContext {
if g.currentCoroutineScope == "" {
return "", fmt.Errorf("Go function requires an ambient coroutine context")
}
args = append([]string{g.currentCoroutineScope + ".Context()"}, args...)
}
}
callee, err := g.expr(e.Callee, "")
if err != nil {