32699 Commits

Author SHA1 Message Date
mlugg
cac814cf58
Sema: fix comparison between error set and comptime-known error union
Resolves: #20613
2025-02-05 20:13:56 +00:00
mlugg
9ba9f457be
Sema: add fast path to PTR when all types are the same
I have no idea why I didn't add this when I first implemented this PTR
logic.
2025-02-05 19:56:43 +00:00
mlugg
fbe0ae4fd4
Sema: fix PTR of slice of sentinel-terminated array
Resolves: #20901
2025-02-05 19:53:12 +00:00
mlugg
0f38558435
compiler: provide result type to sentinel expression in slice operation
Resolves: #21867
2025-02-05 19:36:14 +00:00
mlugg
456f3c026b
Sema: fix crash on @tagName of undefined enum literal
Resolves: #20826
2025-02-05 19:08:05 +00:00
mlugg
3ce857d054
Sema: fix incorrectly succeeding type resolution
Resolves: #21436
2025-02-05 18:31:39 +00:00
Scott Redig
ff551374a0 fix typo of anytype to type
This seems like a simple typo.  The values are immediately used in a struct as types, so there's no reason to use anytype here, afaik.
2025-02-05 13:58:15 +01:00
Matthew Lugg
f01f1e33c9
Merge pull request #22754 from mlugg/files-and-stuff
ZON and incremental bits
2025-02-05 12:17:13 +00:00
Will Lillis
cf059ee087
AstGen: improve error for invalid bytes in strings and comments 2025-02-05 11:10:11 +02:00
Andrew Kelley
d72f3d353f
Merge pull request #22691 from squeek502/child-internal-array-list
Document that the `ptr` field of Allocator/Random should not be compared and remove existing comparison
2025-02-04 13:35:59 -08:00
mlugg
bebfa036ba
test: remove failing case
Unfortunately, now that this error is more in line with other `@import`
errors, it isn't so easy to have a test case for.
2025-02-04 18:30:50 +00:00
mlugg
d60910c9d0
incremental: add ZON test 2025-02-04 16:20:30 +00:00
mlugg
fb481d0bf8
Zcu: fix bug clearing compile errors
And add an assertion in safe builds that our initial check is actually
correct.
2025-02-04 16:20:30 +00:00
mlugg
3ca588bcc6
compiler: integrate importing ZON with incremental compilation
The changes from a few commits earlier, where semantic analysis no
longer occurs if any Zig files failed to lower to ZIR, mean `file`
dependencies are no longer necessary! However, we now need them for ZON
files, to be invalidated whenever a ZON file changes.
2025-02-04 16:20:29 +00:00
mlugg
55a2e535fd
compiler: integrate ZON with the ZIR caching system
This came with a big cleanup to `Zcu.PerThread.updateFile` (formerly
`astGenFile`).

Also, change how the cache manifest works for files in the import table.
Instead of being added to the manifest when we call `semaFile` on them,
we iterate the import table after running the AstGen workers and add all
the files to the cache manifest then.

The downside is that this is a bit more eager to include files in the
manifest; in particular, files which are imported but not actually
referenced are now included in analysis. So, for instance, modifying any
standard library file will invalidate all Zig compilations using that
standard library, even if they don't use that file.

The original motivation here was simply that the old logic in `semaFile`
didn't translate nicely to ZON. However, it turns out to actually be
necessary for correctness. Because `@import("foo.zig")` is an
AstGen-level error if `foo.zig` does not exist, we need to invalidate
the cache when an imported but unreferenced file is removed to make sure
this error is triggered when it needs to be.

Resolves: #22746
2025-02-04 16:20:29 +00:00
mlugg
0907432fff
compiler: a few renames
This is mainly in preparation for integrating ZonGen into the pipeline
properly, although these names are better because `astGenFile` isn't
*necessarily* running AstGen; it may determine that the current ZIR is
up-to-date, or load cached ZIR.
2025-02-04 16:20:29 +00:00
mlugg
a8e53801d0
compiler: don't perform semantic analysis if there are files without ZIR 2025-02-04 16:20:29 +00:00
mlugg
5e20a47469
Zcu: remove unused parse_failure field from File.Status
These are reported as `astgen_failure` instead.
2025-02-04 16:20:29 +00:00
mlugg
d3ca10d5d8
Zcu: remove *_loaded fields on File
Instead, `source`, `tree`, and `zir` should all be optional. This is
precisely what we're actually trying to model here; and `File` isn't
optimized for memory consumption or serializability anyway, so it's fine
to use a couple of extra bytes on actual optionals here.
2025-02-04 16:20:29 +00:00
Meghan Denny
3a4bb47fed std.meta.FieldType: use builtin and deprecate 2025-02-04 16:12:10 +00:00
Ryan Liptak
4041cc06d5 Allocator/Random: document that comparing ptr may result in illegal behavior
See #21756 and #17704
2025-02-03 17:07:28 -08:00
Ryan Liptak
b46f9945a8 process.Child.collectOutput: Switch to Allocator/ArrayListUnmanaged
Removes an inadvisable comparison of Allocator.ptr fields
2025-02-03 17:07:27 -08:00
Alex Rønne Petersen
08d661fcfd
Merge pull request #22725 from mrjbq7/timerfd_clockid_t
Fix timerfd_clockid_t on linux and freebsd
2025-02-03 22:51:13 +01:00
Matthew Lugg
317722b37b
Merge pull request #20271 from MasonRemaley/zon
ZON
2025-02-03 16:38:35 +00:00
Alex Rønne Petersen
e61acd8eb5
Merge pull request #22713 from mikdusan/openbsd
openbsd: fix stage3 link
2025-02-03 17:34:55 +01:00
John Benediktsson
7309a13bd8 std.c: fix timerfd_clockid_t.MONOTONIC on freebsd 2025-02-03 15:44:27 +01:00
John Benediktsson
d358ef804e std.c: use linux.timerfd_clockid_t 2025-02-03 15:44:27 +01:00
John Benediktsson
6a1b76a02c std.os.linux: re-add missing timerfd_create() constants 2025-02-03 15:44:27 +01:00
Meghan Denny
7ac110ac25 meta: fix failing test case affecting master 2025-02-03 14:54:39 +01:00
mlugg
dc5c827847
std.heap.GeneralPurposeAllocator: disable some tests on wasm32-wasi
The ZON PR (#20271) is causing these tests to inexplicably fail. It
doesn't seem like that PR is what's breaking GPA, so these tests are now
disabled. This is tracked by #22731.
2025-02-03 09:17:52 +00:00
Mason Remaley
13c6eb0d71
compiler,std: implement ZON support
This commit allows using ZON (Zig Object Notation) in a few ways.

* `@import` can be used to load ZON at comptime and convert it to a
  normal Zig value. In this case, `@import` must have a result type.
* `std.zon.parse` can be used to parse ZON at runtime, akin to the
  parsing logic in `std.json`.
* `std.zon.stringify` can be used to convert arbitrary data structures
  to ZON at runtime, again akin to `std.json`.
2025-02-03 09:14:37 +00:00
Will Lillis
953355ebea
fix: error on non-exhaustive enums with zero width backing type (#21374)
Co-authored-by: WillLillis <wlillis@umass.edu>
2025-02-02 03:36:16 +00:00
Andrew Kelley
963651bbf2
Merge pull request #22672 from jacobly0/x86_64-rewrite
x86_64: rewrite float conversions
2025-02-01 14:32:43 -08:00
Michael Dusan
1c288ee857
std.Target: bump semver min/max for BSDs and Apple 2025-02-01 14:47:10 -05:00
dweiller
cdc9d65b0d std.priority_queue: add useful functions from ArrayList API
The `ensureTotalCapacityPrecise`, `clearRetainingCapacity` and
`clearAndFree` functions from the ArrayList API are also useful for a
PriorityQueue.
2025-02-01 19:02:39 +01:00
Michael Dusan
127b0921ba
openbsd: fix stage3 link
- llvm requires libexecinfo which has conflicting symbols with libc++abi
- workaround is to link c++abi dynamically
2025-02-01 12:16:21 -05:00
mlugg
3924f173af compiler: do not propagate result type to try operand
This commit effectively reverts 9e683f0, and hence un-accepts #19777.
While nice in theory, this proposal turned out to have a few problems.

Firstly, supplying a result type implicitly coerces the operand to this
type -- that's the main point of result types! But for `try`, this is
actually a bad idea; we want a redundant `try` to be a compile error,
not to silently coerce the non-error value to an error union. In
practice, this didn't always happen, because the implementation was
buggy anyway; but when it did, it was really quite silly. For instance,
`try try ... try .{ ... }` was an accepted expression, with the inner
initializer being initially coerced to `E!E!...E!T`.

Secondly, the result type inference here didn't play nicely with
`return`. If you write `return try`, the operand would actually receive
a result type of `E!E!T`, since the `return` gave a result type of `E!T`
and the `try` wrapped it in *another* error union. More generally, the
problem here is that `try` doesn't know when it should or shouldn't
nest error unions. This occasionally broke code which looked like it
should work.

So, this commit prevents `try` from propagating result types through to
its operand. A key motivation for the original proposal here was decl
literals; so, as a special case, `try .foo(...)` is still an allowed
syntax form, caught by AstGen and specially lowered. This does open the
doors to allowing other special cases for decl literals in future, such
as `.foo(...) catch ...`, but those proposals are for another time.

Resolves: #21991
Resolves: #22633
2025-02-01 15:48:45 +00:00
Matthew Lugg
c225b780e3
Merge pull request #22708 from mlugg/memcpy-alias-zero-bit
Sema: skip aliasing check and runtime operation for `@memcpy` of zero-bit type
2025-02-01 15:47:06 +00:00
mlugg
149031204c
Sema: skip aliasing check and runtime operation for @memcpy of zero-bit type
This check isn't valid in such cases, because the source and destination
pointers both refer to zero bits of memory, meaning they effectively
never alias.

Resolves: #21655
2025-02-01 09:48:18 +00:00
mlugg
d97441d37e
Sema: fix @splat of OPV arrays 2025-02-01 09:46:29 +00:00
Chris Boesch
58c00a829e
std.posix: Use separate clock ID enums for clock_gettime() and timerfd_create() (#22627) 2025-02-01 06:53:57 +00:00
Jacob Young
4c5abe5ac6 x86_64: rewrite vector @intCast 2025-01-31 23:09:58 -05:00
Jacob Young
f0ac14ce97 x86_64: rewrite scalar @intCast 2025-01-31 23:09:36 -05:00
Jacob Young
b9531f5de6 x86_64: rewrite float vector conversions 2025-01-31 23:00:34 -05:00
Jacob Young
afa74c6b21 Sema: introduce all_vector_instructions backend feature
Sema is arbitrarily scalarizing some operations, which means that when I
try to implement vectorized versions of those operations in a backend,
they are impossible to test due to Sema not producing them. Now, I can
implement them and then temporarily enable the new feature for that
backend in order to test them. Once the backend supports all of them,
the feature can be permanently enabled.

This also deletes the Air instructions `int_from_bool` and
`int_from_ptr`, which are just bitcasts with a fixed result type, since
changing `un_op` to `ty_op` takes up the same amount of memory.
2025-01-31 23:00:34 -05:00
Jacob Young
8195b64f57 x86_64: rewrite scalar float conversions 2025-01-31 23:00:34 -05:00
Michael Dusan
c44be99f1a debug: fix MemoryAccessor file leak
- patch authored by Jacob Young
- tested on alpine-aarch64, 3.21.0, qemu-system 9.2.0
- issue manifested on Alpine Linux aarch64 under qemu-system where
  zig2 fails during bootstrap: error.ProcessFdQuotaExceeded
2025-02-01 04:27:24 +01:00
Alex Kladov
4de2b1ea65 std: don't leak a process in Child.run in case of an error
Closes: #22433
2025-01-31 17:57:39 +01:00
John Benediktsson
c104e86442
std.os.linux: adding recvmmsg() (#22651) 2025-01-31 15:44:50 +00:00
Alex Rønne Petersen
a5b8a2938d
glibc: Update abilists file to 2.41. 2025-01-31 14:38:23 +01:00