fix(yaegiutil): refuse incomplete Yaegi interface wrappers at load
The generated symbol tables carried 25 hand-added nil guards across three
packages, re-applied by hand after every regeneration because `yaegi extract`
does not emit them. Regeneration silently dropped them, and three package docs
instructed the next agent to put them back.
The guards also answered the wrong way. A nil WResolve returned ("", nil), so a
malformed secret engine served an empty secret and reported success; a nil
WStop reported a clean shutdown for a module that never ran one.
Reject the wrapper where it enters the daemon instead. Yaegi type-checks
"var X Iface = impl{}" and refuses an incomplete impl on its own, but the
wrapper type is exported into the symbol table, so interpreted code can build
one directly and struct-literal semantics leave the omitted method nil.
Resolve now names the missing method and skips the plugin.
Generated tables are used verbatim again. Also names the wanted type on a
failed assertion, which formatted as "want <nil>" for every interface target.
This commit is contained in:
1 parent
b2fcf25c0b
commit
d4ce6799b6
16 files changed
+212
-361
No files matched your search
@@ -18,9 +18,11 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/yaegiutil"
|
||||
)
|
||||
|
||||
// Plugin is a core plugin loaded by the daemon at startup. Each .go file
|
||||
// in ~/.config/archie/plugins/ must export a variable named "Plugin" that
|
||||
// satisfies this interface.
|
||||
// Plugin is a core plugin loaded by the daemon at startup. Each .go file in
|
||||
// ~/.config/archie/plugins/ must export a variable named "Plugin" declared
|
||||
// with an interface type: "var Plugin plugin.Plugin = impl{}". A
|
||||
// concrete-typed export is refused, because Yaegi only bridges an interpreted
|
||||
// value to Go as an interface when the declaration names one.
|
||||
type Plugin interface {
|
||||
Name() string
|
||||
Version() string
|
||||
|
||||
Reference in new issue
Block a user