Repository navigation
Batch: merge a transitive module's @externs, faults and actors; tcp.close_reset; discarded-call trailing block; a local lasts to the end of its function (#3872) - #3877
Merged
Conversation
`_ = f() { ... }` took the `_` discard path, which emitted `(void)(f())`
and never looked at the call's trailing block, so the block vanished
without a diagnostic. The same call bound to a name runs the block with
the value as its context.
The discard now binds the value to a temporary, pushes it as the
context, runs the block, and throws the value away, freeing a fresh
string. A builder's block already ran ahead of the call and is left as
it was.
tests/regression/test_trailing_block_discard.ae fails on 0.941.0 and
passes here; it covers an int, a fresh string, and a discard nested in
another's block, and is clean under macOS leaks. Mac make test-ae
2357/0; ae-x64 CC=gcc make ci green, 2382/0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With `import std.math (math_sin)` and `import a (sq)` in one module, the program importing that module failed in `a`'s own `math.sqrt(x)` with E0301 "Undefined function 'math.sqrt'". A module the program reaches only through other modules' imports is merged by the transitive pass (#243), which kept its own copy of the direct pass's per-declaration merge. The copy had functions, constants and types, but not `@extern("sym") name(...)` declarations (cloned as `<ns>_<name>` so a qualified `ns.name(...)` resolves, #234), fault sets, messages, protocols or actors. So in such a module a qualified call of its own `@extern` was E0301, a fault it returned was E0300 "Undefined variable '<ns>_<Fault>'", and an actor it spawned was "Undefined function 'spawn_<Actor>'". A bare import anywhere on the path had the #870 synthetic import merge the module through the direct pass, which hid the gap; an all-selective path left only the transitive copy. #3852 (0.944.0) made std.math's sqrt, floor, ceil, round, abs, min, max and clamp `@extern`s, which exposed it for std.math; the same program built on 0.941.0, where they were bare externs. The fault and actor cases failed on 0.941.0 as well. The direct pass's loop is now merge_module_decls, and both passes call it. Regression: tests/integration/transitive_selective_import_merge (a user module's `@extern`s, std.math's, a fault set, a message and an actor, all reached through selective imports only), failing before the fix with six errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/integration/http_proxy_reset_is_502 failed on FreeBSD, on main as well: its upstream closes the proxy's retry connection with the request unread to reset it, and the 502 it got read "the connection closed with no response" rather than naming the reset. A close with bytes unread resets on Linux, macOS and Windows; FreeBSD ends the connection with a FIN, which the client rightly reports as a bare close. tcp.close_reset(sock) (tcp_close_reset_raw) sets SO_LINGER on with a zero timeout and closes, so the peer's next read or write fails with ECONNRESET on every platform. The test's upstream resets the retry connection with it. std/tcp/README.md and docs/api regenerated. Verified on FreeBSD 15.1: both cases of the test fail on main and pass with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"256 KiB echoed whole under a deadline and a cancel handle" wrote all
256 KiB to the echo peer before reading any of it back. The peer echoes as
it reads, so once the echo fills this side's receive buffer the peer stops
reading, its receive buffer and this side's send buffer fill, and the
write stalls until the 20 s deadline wherever the loopback buffers hold
less than the 256 KiB in flight. It failed so in a full FreeBSD sweep
("write [deadline exceeded], 0 bytes back") and passed alone. The case now
writes 16 KiB and reads it back before the next, so at most 16 KiB is in
flight; what it checks is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A local first bound in a loop or `if` body hid the function of its name to the end of the function in the generated C (codegen names it `ae_local_<name>` from its first binding on), but the checker's scope of it closed with the body, so a call of the function after the body was accepted and failed in the C compiler on an undeclared `ae_local_<name>`. As decided on the issue, a local lives to the end of its function, as the language reference and E0301's hint already say: the checker now refuses such a call with E0301, as it does one after a binding in the function's own body. A local that holds a closure is called through, and is left alone. A closure's own local is the closure's: codegen renamed a call of the function after the closure too, the same C failure, on 0.941.0 as well. The rename now ends with the closure that bound it. Tests: local_named_after_called_function gains a loop and a branch case (refused, E0301 twice) and a closure case (runs, "6 5"); it fails on the compiler before this change. The language reference says the rule outright. Mac make test-ae 2359/0. Closes #3872 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Five commits, one fix each.
1. codegen: run a trailing block on a discarded call (90f9a4d)
_ = f() { … }ran the call but dropped its trailing block; regression test test_trailing_block_discard.ae2. merge: one merge path for a direct and a transitive import
A regression in 0.944.0 and 0.945.0; 0.941.0 is fine:
fails with
E0301 Undefined function 'math.sqrt'ina.ae.A module the program reaches only through other modules' imports is merged by the transitive pass (#243), which kept its own copy of the direct pass's per-declaration merge. That copy had functions, constants and types, but no
@extern("sym") name(...)declarations, fault sets, messages, protocols or actors. A bare import anywhere on the path made the #870 synthetic import merge the module directly and hid the gap. #3852 (0.944.0) made std.math'ssqrt,floor,ceil,round,abs,min,maxandclampinto@externs, which exposed it. The same gap made a fault returned by such a module E0300 (Undefined variable '<ns>_<Fault>') and an actor it spawnsUndefined function 'spawn_<Actor>'; both of those fail on 0.941.0 too.The direct pass's loop is now
merge_module_decls, and both passes call it. Bisected to c0c4783 (#3852): the compiler commits in v0.941.0..v0.945.0 don't change this path. Regression test:tests/integration/transitive_selective_import_merge. It fails before the fix with six errors and passes after.3. std.tcp: close_reset, a close that resets on every platform
tests/integration/http_proxy_reset_is_502fails on FreeBSD, on main as well. Its upstream closes a connection with the request unread to reset it. Linux, macOS and Windows reset in that case, but FreeBSD closes with a FIN, so the 502 said "the connection closed with no response" instead of naming the reset. The newtcp.close_reset(sock)(tcp_close_reset_raw,SO_LINGERon with a zero timeout) resets on every platform, and the test uses it. README, docs/api and the stdlib index are updated. It cross-builds for x86_64-windows and runs under Wine.4. tcp_deadline_cancel: echo 256 KiB a chunk at a time
The "256 KiB echoed whole" case wrote all 256 KiB to an echo peer before reading any of it back. Wherever loopback buffers hold less than that, the write stalls until the 20 s deadline. It failed that way in a full FreeBSD sweep and passed when run alone. The case now writes 16 KiB and reads it back before sending the next chunk.
5. checker: a local lasts to the end of its function (0eb0b29)
A local lives to the end of its function: a call to the function it hid, made after the loop or branch that bound it, is E0301, and codegen no longer renames a closure's own local outside the closure.
Closes #3872
Verification (lab lanes)
make test786/786;make test-ae2381 pass, 0 fail, 34 skip; check-examples, test-install, test-differential, test-release-archive and check-archive-exports-nozlib all pass. Main failshttp_proxy_reset_is_502there.CC=gcc make ci(compiler built with -Werror), on 0eb0b29: CI passed;make test-ae2384 pass, 0 fail, 31 skip.make test-aeon 0eb0b29: 2359 pass, 0 fail.🤖 Generated with Claude Code