Commit Graph

37325 Commits

Author SHA1 Message Date
Matthew Lugg 1364cba90d behavior: update for type resolution changes 2026-03-10 10:26:11 +00:00
Matthew Lugg be4c4ce278 Zcu: improve dependency loop errors with only one item
In this case, we can write the error much more simply.
2026-03-10 10:26:10 +00:00
Matthew Lugg e2669689c4 behavior: auto structs with zero fields are not extern types 2026-03-10 10:26:10 +00:00
Matthew Lugg c9fc921abd tests: update for accepted language change
Pointers to comptime-only types (e.g. `*type`) are no longer themselves
comptime-only types. This means explicit `comptime` annotations are
required in a few more places. However, it also introduces the ability
to access pointers to (including slices of) comptime-only types at
runtime, provided only runtime fields are being accessed.
2026-03-10 10:26:10 +00:00
Matthew Lugg 21b42af5aa tests: update for accepted language change
`@sizeOf` and `@bitSizeOf` are now more restricted: they are not allowed
on comptime-only or NPV (uninstantiable) types. This is because there is
no correct way to actually use the returned ABI size (e.g. you cannot
copy a comptime-only type by copying all of its runtime bits), so having
a non-zero return value had no benefit and was simply confusing.
2026-03-10 10:26:10 +00:00
Matthew Lugg a226008e32 Sema: minor fix 2026-03-10 10:26:10 +00:00
Matthew Lugg f9183edf08 tests: update for accepted language change
`packed struct`s and `packed union`s can no longer contain pointer
fields. There are a few reasons for this, but in particular, binary
formats do not typically support the relocation types we would need to
lower such values into static memory. See the proposal at
https://github.com/ziglang/zig/issues/24657 for details.
2026-03-10 10:26:10 +00:00
Matthew Lugg 031d109310 Sema: small error message fix 2026-03-10 10:26:10 +00:00
Matthew Lugg da2006a38c tests: unions without fields need not store their tag at runtime
...because the union semantically has no possible value so cannot be
stored to or loaded from memory anyway.
2026-03-10 10:26:10 +00:00
Matthew Lugg 4f7344dec0 tests: update for accepted language change
Unions with no fields are now "uninstantiable" types, which work like
`noreturn` in that values of this type cannot exist. Enums with no
fields are different because they are currently considered `extern`
types, though https://github.com/ziglang/zig/issues/19855 will change
this in the future.
2026-03-10 10:26:10 +00:00
Matthew Lugg ffc5242169 Sema: small NPV fixes 2026-03-10 10:26:10 +00:00
Matthew Lugg 5c41b6db87 Sema: disallow empty extern/packed unions
These types don't really make much sense: you can't pack together bits
of a type which cannot exist, nor can you pass it over an ABI boundary.
2026-03-10 10:26:09 +00:00
Matthew Lugg 96d6b22067 tests: update for accepted language change
'comptime_int' is no longer considered a valid backing type for an enum.
In other words, 'enum(comptime_int)' is a compile error. This change is
accepted to simplify the language.
2026-03-10 10:26:09 +00:00
Matthew Lugg 4e92592fee compiler: error set bugfixes 2026-03-10 10:26:09 +00:00
Matthew Lugg 03e23bcbde resolve some of my TODOs 2026-03-10 10:26:09 +00:00
Matthew Lugg c91b06ef52 incr-check: fix successful -fno-emit-bin updates 2026-03-10 10:26:09 +00:00
Matthew Lugg 1826ba69d8 compiler: make dependency loop errors good 2026-03-10 10:26:09 +00:00
Matthew Lugg a9bfc94ee6 compiler: small misc cleanups 2026-03-10 10:26:09 +00:00
Matthew Lugg b8997f871f Sema: clean up and fix alignment handling 2026-03-10 10:26:09 +00:00
Matthew Lugg 38fdced8bb Sema: small cleanup 2026-03-10 10:26:09 +00:00
Matthew Lugg 650185692d compiler: merge struct default value resolution into layout resolution
This actually doesn't cause any dependency loops in std, which is pretty
much my benchmark for it being acceptable. This can be reverted if it
turns out to be problematic, but for now, let's err on the side of
language simplicity.

To be clear, this *does* regress some cases which previously worked: I
will have to remove some behavior tests as a result of this commit. To
be honest, the tests which look to be failing as a result of this are
things which I think are generally unadvisable; I actually reckon a bit
more friction to use default field values in non-trivial ways might be a
good thing to stop people from misusing them as much. Struct fields
should very rarely have default values; about the only common situation
where they make sense is "options" structs.
2026-03-10 10:26:08 +00:00
Matthew Lugg 8eefe86939 std: remove default values from ArrayList
These were deprecated in the 0.14.0 release cycle almost a year ago, so
they can definitely be deleted now.
2026-03-10 10:26:08 +00:00
Matthew Lugg 187fef209f compiler: rework OPV and noreturn-like types 2026-03-10 10:26:08 +00:00
Matthew Lugg b19074d252 compiler: represent bitpacks as their backing integer
Now that https://github.com/ziglang/zig/issues/24657 has been
implemented, the compiler can simplify its internal representation of
comptime-known `packed struct` and `packed union` values. Instead of
storing them field-wise, we can simply store their backing integer
value. This simplifies many operations and improves efficiency in some
cases.
2026-03-10 10:26:08 +00:00
Matthew Lugg 911294116d compiler: make type resolution lazy
...and rework some of the incremental reference tracking. Almost all
kinds of AnalUnit have one property in common: they might never be
referenced in any update despite conceptually "existing", in which case
we don't want to waste time semantically analyzing them. As of the lazy
type resolution introduced in this commit, the only units to which this
does not apply are `memoized_state` and `@"comptime"`. Previously, I had
a somewhat hacky system in `Zcu` for dealing with this, but I now have a
better understanding of the design incremental compilation is converging
on, so can implement a better solution. By finding a few unused bits
lying around (...or making them), we can represent a single bit of state
indicating whether something's corresponding units have ever been
referenced. This is akin to the units being in `Zcu.outdated`, with the
key difference being that the compiler will *not* attempt to analyze
units which are in this state. Once they are first referenced or
depended on, the flag is set to true and the unit is added to `outdated`
so that it can participate in the normal dependency resolution logic.
2026-03-10 10:26:08 +00:00
Matthew Lugg 334189ce6d compiler: simplify IESes
It is always a bug in Sema to check whether an IES is resolved. This is
because whether the IES is resolved depends on whether the function
which owns it has been analyzed yet, which depends on the order the
compiler analyzes declarations in, which it is incorrect to have any
dependency on. Instead, we must always either not look at the resolved
set, or resolve it first (with `Sema.ensureFuncIesResolved`) and then
look at the definitely-resolved concrete error set.

Luckily, removing a bunch of the buggy logic which tried to
opportunistically use already-resolved inferred error sets actually
didn't regress anything! It seems this logic was mostly left over from
before Andrew reworked inferred error sets, and had become essentially
dead code. This is because inferred error sets are stricter than they
used to be, and in particular, we make no attempt to support mutual
recursion.

I suspect that most of the logic touching IESes can be simplified even
further than I have done here without regressing any existing code; my
goal in this commit was just to remove any *buggy* code I could find.
2026-03-10 10:26:08 +00:00
Matthew Lugg e3e9ae12bd Sema: remove unnecessary error sets from resolveInst and resolveValue 2026-03-10 10:26:07 +00:00
Matthew Lugg 3086c7977b type resolution progress 2026-03-10 10:26:07 +00:00
Matthew Lugg 6e49697ef5 backend progress
The x86_64 backend now compiles and, with `-fstrip`, kinda works!
2026-03-10 10:26:07 +00:00
Matthew Lugg 792830d69c std: work around language changes 2026-03-10 10:26:07 +00:00
Matthew Lugg 510ea6f61f type resolution progress 2026-03-10 10:26:07 +00:00
Matthew Lugg 5e8397d5e0 Zir: rework container type declarations
Only AstGen and print_zir currently support the new representation, so
attempting to build the compiler will emit (many) compile errors.
2026-03-10 10:26:06 +00:00
Alex Rønne Petersen cfe5c88ad6 std.Io.RwLock: disable smoke test on any aarch64 target
https://codeberg.org/ziglang/zig/issues/31393#issuecomment-11441755
2026-03-10 09:19:54 +01:00
Andrew Kelley 5318045b88 std.Io.Writer: document write and writeAll
closes #31435
2026-03-09 21:24:59 -07:00
Andrew Kelley 3b515fbede Merge pull request 'std.Io: move netReceive to become an Operation' (#31089) from net-receive into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31089
2026-03-09 09:09:04 +01:00
Andrew Kelley 80625990d5 std: different mechanism for disabling network dependency
On Windows, it is sometimes problematic to depend on ws2_32.dll. Before,
users of std.Io.Threaded would have to call ioBasic() rather than io()
in order to avoid unnecessary dependencies on ws2_32.dll. Now, the
application can disable networking with std.Options.

This change is necessary due to moving networking functionality to
be based on Io.Operation, which is a tagged union.
2026-03-08 19:20:34 -07:00
Andrew Kelley 85ed81bb94 std.Io.Threaded: implement netReceive for Windows 2026-03-08 19:20:06 -07:00
Andrew Kelley dd8de03720 std.Io.Dispatch: fix compile errors 2026-03-08 19:20:06 -07:00
Andrew Kelley 4cbf30c2a4 std.Io.Uring: implement net_receive operate
Batch implementation still TODO.
2026-03-08 19:20:06 -07:00
Andrew Kelley c2ebbd8911 std.Io.Threaded: implement net_receive for Windows 2026-03-08 19:20:06 -07:00
Andrew Kelley 8b69341271 std.Io.Threaded: optimize batchAwaitConcurrent for net_receive
Eagerly receive messages with MSG_DONTWAIT before polling. This makes
the DNS resolution use case end up doing:

recvmsg (EAGAIN)
poll
recvmsg (success)
recvmsg (success)

rather than:

poll
recvmsg (success)
poll
recvmsg (success)
2026-03-08 19:20:06 -07:00
Andrew Kelley be0f188990 std.Io: move netReceive to become an Operation
Notably, the timeout becomes provided by the general-purpose Batch API
rather than being special-purposed.
2026-03-08 19:20:06 -07:00
Ryan Liptak 6be202f466 Io: Add processSetCurrentPath
The logic used to allow providing a path for setting the CWD of a child process in https://codeberg.org/ziglang/zig/pulls/31090 applies here as well:

- Windows must provide a path when setting the CWD, so the path of an `Io.Dir` must be resolved before actually calling RtlSetCurrentDirectory_U
- A directory handle may have multiple paths associated with it, so providing the CWD as a string retains a legitimate use case in cases where the precise path matters
2026-03-09 03:19:11 +01:00
Andrew Kelley 09bf51092b Revert "Fix #20283"
This reverts commit 30c8a75997.

Better fix landed in f16eb18ce8.
2026-03-08 18:41:21 -07:00
Andrew Kelley dceee570c4 Revert "fix(docs/wasm):zig std html render error function 'a'"
This reverts commit e779ca7223.

Closes #31370
2026-03-08 18:40:57 -07:00
Alex Rønne Petersen 6def6beacd std.zon.parse: disable std.zon parse float on 32-bit x86 in general
https://github.com/ziglang/zig/issues/23922
2026-03-08 19:25:10 +01:00
Alex Rønne Petersen 9598010303 README: update section about --libc-runtimes 2026-03-08 19:25:08 +01:00
Alex Rønne Petersen 2c126b8c82 ci: enable --libc-runtimes with glibc 2.43 and musl 1.2.5 on x86_64-linux 2026-03-08 18:28:05 +01:00
Ryan Liptak f16eb18ce8 Use / as path separator when writing tar files
The tar format expects `/`, although some untar implementations do seem to handle Windows-style `\` path separators (7-Zip at least).

The tar.Writer API can't really enforce this, though, as doing so would effectively make `\` an illegal character when it's really not. So, it's up to the user to provide paths with the correct path separators.

`Build/WebServer.zig` will still output tars with `\` as a path separator on Windows, but that's currently only used during fuzzing which is not yet implemented on Windows.
2026-03-08 02:10:00 +01:00
Alex Rønne Petersen c91bb87b01 std.zig.target: enable loongarch64-linux-muslf32
This should still be considered an experimental target as the LP64F ABI has not
been stabilized yet.
2026-03-08 02:01:26 +01:00