Summary
The constructor signature is New[E Engine](ctx context.Context, src Source, opts ...Option[E]), but every New example in README.md and three examples in the polyscript.go package doc omit the leading ctx. Copied verbatim, they do not compile. The direct-subpackage examples similarly omit ctx from FromRisorLoader/FromExtismLoader, whose signatures also take ctx first. The New godoc itself (polyscript.go:226-232) shows ctx correctly, so the package is internally inconsistent.
Locations
README.md — New examples
| Line |
Call |
| 68 |
New[polyscript.Risor](FromString(script), WithStaticData...) (quick start) |
| 118 |
New[polyscript.Risor](FromFile(...)) |
| 149 |
New[polyscript.Risor](FromLoader(httpLoader)) |
| 164 |
New[polyscript.Risor](FromString(script), WithLogHandler..., WithStaticData...) |
| 180 |
New[polyscript.Risor](FromString(script), WithStaticData...) |
| 191 |
New[polyscript.Risor](FromString(script)) |
| 226 |
New[polyscript.Risor](FromString(script), WithStaticData...) |
| 281 |
New[polyscript.Starlark](FromString..., WithStaticData...) |
| 304 |
New[polyscript.Extism](FromBytes..., WithEntryPoint..., WithStaticData...) |
README.md — direct-subpackage examples
- 336 —
risor.FromRisorLoader(ldr, risor.WithStaticData(...)) (actual: FromRisorLoader(ctx, ldr, opts...))
- 356 —
extism.FromExtismLoader(wasmLdr, extism.WithEntryPoint(...), ...) (actual: FromExtismLoader(ctx, ldr, opts...))
polyscript.go — package doc
- 13 —
New[polyscript.Risor](polyscript.FromString(script))
- 21-24 —
New[polyscript.Risor](FromString(script), WithStaticData...)
- 28-31 —
New[polyscript.Extism](FromBytes..., WithEntryPoint...)
Why CI didn't catch it
readme_test.go passes t.Context() as the first argument to every New call (lines 34, 70, 97, 139, 172, 192), so the tests compile and pass. They validate the snippets' logic, not the exact source shown in the README, so the drift is invisible.
Fix
Prepend ctx (context.Background() in README prose, ctx/t.Context() where a context is in scope) to every listed example. Consider generating README snippets from compiled example files to keep them honest.
Summary
The constructor signature is
New[E Engine](ctx context.Context, src Source, opts ...Option[E]), but everyNewexample inREADME.mdand three examples in thepolyscript.gopackage doc omit the leadingctx. Copied verbatim, they do not compile. The direct-subpackage examples similarly omitctxfromFromRisorLoader/FromExtismLoader, whose signatures also takectxfirst. TheNewgodoc itself (polyscript.go:226-232) showsctxcorrectly, so the package is internally inconsistent.Locations
README.md —
NewexamplesNew[polyscript.Risor](FromString(script), WithStaticData...)(quick start)New[polyscript.Risor](FromFile(...))New[polyscript.Risor](FromLoader(httpLoader))New[polyscript.Risor](FromString(script), WithLogHandler..., WithStaticData...)New[polyscript.Risor](FromString(script), WithStaticData...)New[polyscript.Risor](FromString(script))New[polyscript.Risor](FromString(script), WithStaticData...)New[polyscript.Starlark](FromString..., WithStaticData...)New[polyscript.Extism](FromBytes..., WithEntryPoint..., WithStaticData...)README.md — direct-subpackage examples
risor.FromRisorLoader(ldr, risor.WithStaticData(...))(actual:FromRisorLoader(ctx, ldr, opts...))extism.FromExtismLoader(wasmLdr, extism.WithEntryPoint(...), ...)(actual:FromExtismLoader(ctx, ldr, opts...))polyscript.go — package doc
New[polyscript.Risor](polyscript.FromString(script))New[polyscript.Risor](FromString(script), WithStaticData...)New[polyscript.Extism](FromBytes..., WithEntryPoint...)Why CI didn't catch it
readme_test.gopassest.Context()as the first argument to everyNewcall (lines 34, 70, 97, 139, 172, 192), so the tests compile and pass. They validate the snippets' logic, not the exact source shown in the README, so the drift is invisible.Fix
Prepend
ctx(context.Background()in README prose,ctx/t.Context()where a context is in scope) to every listed example. Consider generating README snippets from compiled example files to keep them honest.