5895 Commits

Author SHA1 Message Date
N00byEdge
18440cb239
std.mem.zeroes: Zero sized structs with uninitialized members (#12246)
`std.mem.zeroes(struct{handle: void})` Failed with the following error before:
```
/nix/store/l6v4359wc9xrxxmvvp3rynsb5s3d78xf-zig-0.9.1/lib/zig/std/mem.zig:270:42: error: missing field: 'handle'
            if (@sizeOf(T) == 0) return T{};
                                         ^
```
2022-08-05 15:47:52 +03:00
Allan Regush
44c321c05e std.enums: make directEnumArrayLen public 2022-08-05 15:41:03 +03:00
Felix "xq" Queißner
263b5933d2 Makes std.meta.Tuple and std.meta.ArgsTuple generate a unique type instead of generating one per invocation. 2022-08-05 15:39:53 +03:00
Stephen Gregoratto
b3950d4a88 Update Linux syscall list for 5.19
New changes: memfd_secret implemented for RISC-V.
2022-08-05 15:36:32 +03:00
Loris Cro
7ffba492a5 autodoc: fix inconsistency when indexing generic types for search
closes #12334
2022-08-05 00:11:32 +02:00
Loris Cro
616f65df75 init-exe template: add flushing to the buffered writer 2022-08-04 21:12:42 +02:00
Loris Cro
cbac7a0194 init-exe template: small improvements 2022-08-04 20:27:46 +02:00
Loris Cro
fb0b9f05b3 new init-exe template
- removed an unnecessary (and confusing) `anyerror` fronm the function
  signature of `main`
- replaced the call to std.log with two prints: one to stderr and one to
  stdout
- replaced the test code with a better example
2022-08-04 20:10:43 +02:00
Jakub Konka
421d3e8d28 macho: add missing align cast in LoadCommandIterator 2022-08-03 21:19:41 +02:00
Jakub Konka
bb532584bc macho: update how we insert output sections
Instead of generating sections upfront, allow generation by scanning
the object files for input -> output sections mapping. Next, always
strive to keep output sections in the final container sorted as they
appear in the final binary. This makes the linker less messy wrt
handling of output sections sort order for dyld/macOS not to complain.
There's still more work to be done for incremental context though
to make this work but looks promising already.
2022-08-03 21:19:41 +02:00
Jakub Konka
f26d5ee7ea macho: sync with zld
gitrev a2c32e972f8c5adfcda8ed2d99379ae868f59c24

a2c32e972f
2022-08-03 21:19:41 +02:00
Loris Cro
4c750016eb autodoc: inferred error unions in function return values 2022-08-03 17:21:56 +02:00
Frank Denis
fa321a07cd
crypto.sign.ed25519: include a context string in blind key signatures (#12316)
The next revision of the specification is going to include a context
string in the way blinded scalars are computed.

See:
https://github.com/cfrg/draft-irtf-cfrg-signature-key-blinding/issues/30#issuecomment-1180516152
https://github.com/cfrg/draft-irtf-cfrg-signature-key-blinding/pull/37
2022-08-03 15:25:15 +02:00
Loris Cro
c5afefec42 autodoc: fix autodoc analysis for @typeInfo
We were previously erroneously saving it as a `@TypeOf`.
2022-08-02 17:49:36 +02:00
Loris Cro
622714b76b autodoc: fix frontend crash while rendering std.mem
Previously we expected to only find decl refs in a `foo.bar.baz`
type of expression. This would crash when trying to render something
like `@typeInfo(T).Int.bits`. We now properly account for builtins
and other components.
2022-08-02 17:49:36 +02:00
Veikka Tuominen
14f0b70570 Sema: add safety for sentinel slice 2022-08-02 18:34:30 +03:00
Loris Cro
2375658da9
Merge pull request #12276 from r00ster91/shortdesc
autodoc: better short description algorithm
2022-08-02 16:32:08 +02:00
Loris Cro
9ba2377d64
Merge pull request #12305 from squeek502/autodoc-field-doc-borders
autodoc: Add borders to field docs to make it clear which field they are associated with
2022-08-02 16:30:12 +02:00
Ryan Liptak
e7b6a18331 std.fs: Split Iterator.next on Linux and WASI to allow for handling platform-specific errors
Follow up to #12226, implements the compromise detailed in https://github.com/ziglang/zig/issues/12211#issuecomment-1196011590
2022-08-01 19:38:05 +03:00
Ryan Liptak
1a1b7a3afd Linux: Add IN_MASK_CREATE and corresponding error handling in inotify_add_watch
From https://man7.org/linux/man-pages/man7/inotify.7.html

> **IN_MASK_CREATE** (since Linux 4.18)
>
> Watch pathname only if it does not already have a watch associated with it; the error EEXIST results if pathname is already being watched.
2022-07-31 13:00:16 -07:00
Ryan Liptak
921ba6cad4 autodoc: Add borders to field docs to make it clear which field they are associated with 2022-07-30 17:26:29 -07:00
Veikka Tuominen
d26d696ee0 parser: require expression after colon in slice expr 2022-07-30 00:18:08 +03:00
Andrew Kelley
a482517357 std.debug: default signal handler also handles SIGFPE 2022-07-29 02:35:06 -07:00
Meghan Denny
b5861193e0 std: rename std.Target.systemz to .s390x 2022-07-28 23:22:44 -07:00
r00ster91
2c7387aef5 autodoc: better short description algorithm 2022-07-28 21:37:36 +02:00
Andrew Kelley
90f23e131e
Merge pull request #12252 from ziglang/stage3-test-cases
CI: run test-cases with stage3
2022-07-27 10:27:12 -07:00
Andrew Kelley
0527b441ae move zig.h to become an installation file
Now instead of zig.h being baked into the compiler binary, it is a
header file distributed along with all the other header files
distributed with Zig.

Closes #11643
2022-07-27 10:26:45 -07:00
r00ster91
baafb8a491 std.fmt: add more invalid format string errors 2022-07-27 18:07:53 +03:00
r00ster91
4ef7d85810 std.fmt: lowercase compile errors
`compileError\("([A-Z])` and `compileError\("\L\1`. It's pretty convenient.
2022-07-27 18:07:53 +03:00
Evan Haas
7ba1f9bfb5 translate-c: take address of functions before passing them to @ptrToInt
Fixes #12194
2022-07-27 14:03:08 +03:00
Andrew Kelley
a127693f95 start code: enable segfault handler for stage2 2022-07-26 20:04:24 -07:00
Andrew Kelley
0ffcf19e3d
Merge pull request #12237 from Vexu/stage2-compile-errors
Stage2 improve errors for builtin function options structs
2022-07-26 11:26:35 -07:00
InKryption
a0d3a87ce1 std.fmt: require specifier for unwrapping ?T and E!T 2022-07-26 11:25:49 -07:00
r00ster
1a16b7214d
std.mem: add reset to SplitBackwardsIterator and SplitIterator 2022-07-26 14:26:46 +03:00
Veikka Tuominen
a463dc7d6c AstGen: disable null bytes and empty stings in some places
Namely:
 * test names
 * identifiers
 * library names
 * import strings
2022-07-26 12:14:59 +03:00
Veikka Tuominen
2f54129087 parser: add error for doc comment attached to comptime or test blocks 2022-07-26 12:14:59 +03:00
r00ster
cff5d9c805
std.mem: add first method to SplitIterator and SplitBackwardsIterator 2022-07-25 22:04:30 +03:00
VÖRÖSKŐI András
370793a36b PriorityDequeue: use compareFn in update() method 2022-07-25 18:12:32 +03:00
Ryan Liptak
75e5b38410
std.fs: End iteration on Linux/WASI during Iterator.next when hitting ENOENT
`getdents` on Linux can return `ENOENT` if the directory referred to by the fd is deleted during iteration. Returning null when this happens makes sense because:

- `ENOENT` is specific to the Linux implementation of `getdents`
- On other platforms like FreeBSD, `getdents` returns `0` in this scenario, which is functionally equivalent to the `.NOENT => return null` handling on Linux
- In all the usage sites of `Iterator.next` throughout the standard library, translating `ENOENT` returned from `next` as null was the best way to handle it, so the use-case for handling the exact `ENOENT` scenario specifically may not exist to a relevant extent

Previously, ENOENT being returned would trigger `os.unexpectedErrno`.

Closes #12211
2022-07-25 16:14:25 +03:00
r00ster
8f3ab96b0e
std.testing: make the caret indicator line more helpful 2022-07-25 15:51:22 +03:00
Luuk de Gram
7c13bdb1c9
Merge pull request #12059 from Luukdegram/linker-tests-run-step
Implement EmulatableRunStep for linker tests
2022-07-25 06:33:01 +02:00
Ryan Liptak
4624c81899 std.fs: Fix Walker closing the initial directory when not fully iterated
This is a fix for a regression caused by 61c5d8f8f1

Closes #12209
2022-07-24 12:00:14 -07:00
Andrew Kelley
934573fc5d Revert "std.fmt: require specifier for unwrapping ?T and E!T."
This reverts commit 7cbd586ace46a8e8cebab660ebca3cfc049305d9.

This is causing a fail to build from source:

```
./lib/std/fmt.zig:492:17: error: cannot format optional without a specifier (i.e. {?} or {any})
                @compileError("cannot format optional without a specifier (i.e. {?} or {any})");
                ^
./src/link/MachO/Atom.zig:544:26: note: called from here
                log.debug("  RELA({s}) @ {x} => %{d} in object({d})", .{
                         ^
```

I looked at the code to fix it but none of those args are optionals.
2022-07-24 11:50:10 -07:00
Lewis Gaul
a08b0fa706 Fix indexing in the test runner's log formatting 2022-07-24 12:08:02 +03:00
InKryption
7cbd586ace
std.fmt: require specifier for unwrapping ?T and E!T.
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-07-24 12:01:56 +03:00
Ali Chraghi
0b4a3ec950 std: compile error on invalid testing allocator usage 2022-07-24 11:57:00 +03:00
Jonathan Marler
f598234ee8 std.json: expose encodeJsonString and encodeJsonStringChars
Expose 2 functions from std.json.  These functions take a slice of bytes
and forward them to a given writer as a JSON encoded string.

The use case I have for this is in a custom JsonStringWriter.  This writer
takes data and automatically encodes it as JSON string characters and
forwards it to an underlying writer.  I use this JsonStringWriter in
combination with std.fmt.format to go directly from a format string/arg
pair to JSON.  This way I don't have to format my string into a separate
buffer first and encode it afterwards, which avoids the need to create
a temporary buffer to hold the unencoded but formatted string.
2022-07-24 11:51:59 +03:00
Andrew Kelley
a2ab9e36fa
Merge pull request #12143 from Vexu/stage2-safety
Stage2 runtime safety progress
2022-07-23 20:09:24 -07:00
Vincent Rischmann
d99c32c2e1
io_uring: add new flags and opcodes 2022-07-23 17:21:17 +03:00
Veikka Tuominen
d75fa86d70 stage2: implement @setFloatMode 2022-07-23 15:40:12 +03:00