Skip to content

Cover the remaining dynamic call targets for unhandled errors - #17

Merged
marckysharky merged 3 commits into
masterfrom
test/dynamic-call-error-drop
Aug 3, 2026
Merged

Cover the remaining dynamic call targets for unhandled errors#17
marckysharky merged 3 commits into
masterfrom
test/dynamic-call-error-drop

Conversation

@jcmfernandes

@jcmfernandes jcmfernandes commented Jul 30, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Test-only follow-up to the runtime check for unhandled errors from
dynamically-dispatched ! calls.

The spec file that landed with that check covers only two of the dynamic
targets a Starlark program can build, and the Go test covers only a variable
bound to an error-returning builtin. This adds the missing ones:

  • spec/optional/error_handling/dynamic_calls.star — a parameter
    (def f(g): g()) and the result of another call (get_handler()()),
    and a header comment that lists them.
  • starlark/eval_test.go — an attribute of a module-like value
    (fs.read_all(...), via starlarkstruct), and a bare call at module top
    level
    , where the pending error is dropped by the module frame's own return
    rather than a function's.
  • starlark/testdata/dynamic_calls.star — the attribute target exercised from
    Starlark, where the callee behind the struct field is an ordinary !
    function rather than a builtin, so the pending error reaches the caller's
    frame by the other route. The spec suite cannot express this (its predeclared
    vocabulary is assert, trap, matches, freeze, with no way to build an
    attribute-bearing value); the package testdata environment predeclares
    struct, so it belongs there.

Motivation

fs.read_all("//path/to/missing.yml") — an attribute of an embedder module —
is the shape that motivated the runtime check in the first place, and it had no
test. An attribute target is never statically resolvable, so the resolver
always defers to runtime; it is the case the silent drop hit hardest, and the
one most likely to regress unnoticed.

A parameter and a call result are the other two targets expressible in Starlark
alone. Per spec/harness.md, the attribute case cannot live in spec/, which
is why the coverage is split across the three files above.

Additional notes

No production code changes.

How to test the change?

go test ./...

Verified in both directions:

at d44dbe2 (check present) at 1e50f97 (before the check)
go test ./... pass, 12 packages
spec/.../dynamic_calls.star pass 5 assert.fails cases fail
starlark/testdata/dynamic_calls.star pass 2 assert.fails cases fail
TestUnhandledDynamicErrorReturningCallFails 4/4 subtests pass 4/4 subtests fail

Before the check, both new Go cases return None and no error at all:
globals = {result: None, spec: None}.

PR stack

  • master
    • Cover the remaining dynamic call targets for unhandled errors 👈

The spec file landed with only two of the dynamic targets a Starlark
program can build, and the Go test exercised only a variable bound to
an error-returning builtin. The target most embedders actually expose,
an attribute of a module-like value (fs.read_all), went untested even
though it is the shape that motivated the runtime check.

Add the missing targets: a parameter and the result of another call on
the Starlark side, and on the Go side an attribute of a struct plus a
call at module top level, where the pending error is dropped by the
module frame's own return rather than a function's.
@jcmfernandes jcmfernandes self-assigned this Jul 30, 2026
jcmfernandes and others added 2 commits July 30, 2026 19:03
The attribute target was covered only by a Go test, where the callee is
an error-returning builtin. Behind a struct field the callee is instead
an ordinary ! function, so the pending error reaches the caller's frame
by a different route, and no .star test took that route.

The spec suite cannot express this: its predeclared vocabulary is only
assert, trap, matches and freeze, with no way to build an attribute
-bearing value. The package testdata environment predeclares struct, so
the case belongs here.
@marckysharky
marckysharky merged commit 99dca33 into master Aug 3, 2026
5 checks passed
@marckysharky
marckysharky deleted the test/dynamic-call-error-drop branch August 3, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants