Commit Graph

1289 Commits

Author SHA1 Message Date
Andrew Kelley d03a147ea0 Release 0.14.1 2025-05-21 22:46:47 -07:00
Андрей Краевский 8088105b05 std.meta.FieldType -> @FieldType 2025-03-27 12:19:07 +01:00
Andrew Barchuk 0d65b014ea Clarify the multidimensional array example
Use a rectangular matrix instead of a square one to distinguish rows and
columns more clearly. Extend the example with row access.
2025-03-26 15:41:14 +01:00
Andrew Kelley 5ad91a646a Release 0.14.0 2025-03-04 14:31:02 -08:00
Andrew Kelley de43f5eb6a rename "nonce" to "fingerprint" 2025-02-26 11:42:04 -08:00
Andrew Kelley ea516f0e81 bump package id component to 32 bits
and to make the base64 round even, bump sha256 to 200 bits (up from 192)
2025-02-26 11:42:04 -08:00
Andrew Kelley 0fc7c9f57c switch from "id" to "nonce"
mainly this addresses the following use case:

1. Someone creates a template with build.zig.zon, id field included
   (note that zig init does not create this problem since it generates
   fresh id every time it runs).
2. User A uses the template, changing package name to "example" but not
   id field.
3. User B uses the same template, changing package name also to
   "example", also not changing the id field.

Here, both packages have unintentional conflicting logical ids.

By making the field a combination of name checksum + random id, this
accident is avoided. "nonce" is an OK name for this.

Also relaxes errors on remote packages when using `zig fetch`.
2025-02-26 11:42:03 -08:00
Andrew Kelley d6a88ed74d introduce package id and redo hash format again
Introduces the `id` field to `build.zig.zon`.

Together with name, this represents a globally unique package
identifier. This field should be initialized with a 16-bit random number
when the package is first created, and then *never change*. This allows
Zig to unambiguously detect when one package is an updated version of
another.

When forking a Zig project, this id should be regenerated with a new
random number if the upstream project is still maintained. Otherwise,
the fork is *hostile*, attempting to take control over the original
project's identity.

`0x0000` is invalid because it obviously means a random number wasn't
used.

`0xffff` is reserved to represent "naked" packages.

Tracking issue #14288

Additionally:

* Fix bad path in error messages regarding build.zig.zon file.
* Manifest validates that `name` and `version` field of build.zig.zon
  are maximum 32 bytes.
* Introduce error for root package to not switch to enum literal for
  name.
* Introduce error for root package to omit `id`.
* Update init template to generate `id`
* Update init template to populate `minimum_zig_version`.
* New package hash format changes:
  - name and version limited to 32 bytes via error rather than truncation
  - truncate sha256 to 192 bits rather than 40 bits
  - include the package id

This means that, given only the package hashes for a complete dependency
tree, it is possible to perform version selection and know the final
size on disk, without doing any fetching whatsoever. This prevents
wasted bandwidth since package versions not selected do not need to be
fetched.
2025-02-26 11:42:03 -08:00
mlugg cc64295a63 langref: document modules, root source files, etc 2025-02-22 21:01:44 +00:00
mlugg f0b331e95a langref: embrace the term "illegal behavior"
Also standardise the terms "safety-checked" and "unchecked".
2025-02-22 21:01:44 +00:00
mlugg def7e2f20a langref: improve description of @fieldParentPtr 2025-02-22 21:01:44 +00:00
Meghan Denny 933ba935c5 std.BoundedArray: popOrNull() -> pop() [v2] (#22723) 2025-02-09 11:46:15 +00:00
Frank Plowman bf7bc4ff01 langref/errorset: Replace subset description with union
The previous language using subsets was really just stating a couple
of the properties of the union of a group of sets, and with a minor
error at that.
2025-02-07 03:38:44 +01:00
mlugg 249a20d972 langref: clarify restricted @memcpy semantics 2025-01-29 18:43:57 +00:00
87 183bb8b084 langref: Document destructuring (#21627) 2025-01-28 04:23:13 +00:00
isaac yonemoto ae5b1a9ca2 langref: fixes incorrect description of cmpxchg functions 2025-01-26 23:22:04 +01:00
bsubei 3f245616a5 link to Tuples section in Hello World docs, and give an example of an empty tuple 2025-01-26 20:53:25 +01:00
rpkak 9c45fb4b09 langref: correct return type of comptime known bitcount ops 2025-01-26 20:30:06 +01:00
kj4tmp@gmail.com 6255ee3d2f fix typo in @typeName langref 2025-01-26 19:40:57 +01:00
ExeVirus 738d813619 Add zig std to langref.html (#22360) 2025-01-26 18:58:30 +01:00
Andrew Kelley 6d67658965 langref: move pointer casting section out of volatile subsection 2024-12-30 22:05:30 -08:00
Jonathan Marler 77c63ac360 doc: mention zig can't use URLs if their content changes
There's been some proliferation of dependency URLs that reference
mutable data such as links to git branches that can change.  This has
resulted in broken projects, i.e.

* https://github.com/RohanVashisht1234/raylib_rain_train/blob/9eef9de94c511f2eb4fe5db1d6abd574ee245c9b/build.zig.zon
* https://github.com/rcmagic/ZigFightingGame/commit/4b64353e9c69de0fa2eb87fa9c3a3da76a8a3e7b

There's also disagreement about whether it's fine for URL's to point to
git branches, i.e.

https://github.com/Not-Nik/raylib-zig/pull/130

This updates the docs to mention that zig won't be able to use URLs if
their content changes.
2024-12-21 18:23:01 -05:00
Andrew Kelley 3ce6de8765 revert langref section "common errdefer slip ups"
This does not belong in the language reference.

reverts 91a88a789f
2024-11-26 15:03:24 -08:00
Andrew Kelley bfcf18c5a7 langref: delete misleading example code about packed structs 2024-11-13 15:35:16 -08:00
Roman Frołow c39ba682e3 typo: will inlined -> will be inlined 2024-10-29 17:52:55 -07:00
llogick 985b13934d Remove @setAlignStack from the langref 2024-10-25 15:13:41 +02:00
mlugg 04ffc1c963 langref: update enum_export_error.zig for callconv changes 2024-10-19 19:21:33 +01:00
mlugg 097766bba3 compiler: implement @FieldType
Resolves: #21702
2024-10-18 08:50:40 +01:00
wooster0 816dfca0b5 langref: update builtin variadic functions
Documentation was outdated.
2024-10-17 11:51:06 +03:00
David Rubin e131a2c8e2 implement packed struct equality (#21679) 2024-10-12 20:59:12 -07:00
David Rubin 043b1adb8d remove @fence (#21585)
closes #11650
2024-10-04 22:21:27 +00:00
PauloCampana 3e62cb5c90 Remove old deprecated symbols in std (#21584)
Also, actually run tests inside std/tar/writer.zig
2024-10-04 13:50:25 -07:00
LiterallyVoid cf69154332 Labeled switch documentation (#21383)
Add langref docs for labeled switch

This feature was proposed in #8220, and implemented in #21257.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2024-09-12 20:06:49 -07:00
Linus Groh 8588964972 Replace deprecated default initializations with decl literals 2024-09-12 16:01:23 +01:00
Jesse Wattenbarger 218cf059dd remove explicit ComplexTypeTag from switch 2024-09-10 20:28:40 -07:00
Andrew Kelley 37df6ba86e langref: separate header for faulty default field values 2024-08-30 21:12:17 -07:00
mlugg 0fe3fd01dd std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
mlugg 6808ce27bd compiler,lib,test,langref: migrate @setCold to @branchHint 2024-08-27 00:44:35 +01:00
mlugg a3a737e9a6 lib,test,tools,doc: update usages of @export 2024-08-27 00:44:35 +01:00
T eb7f318ea8 langref: clarify functionality of the round builtin (#19503)
A test has also been added to demonstrate the expected behavior.

* std.math: update round doc comment to match the builtin
2024-08-14 10:29:45 -07:00
Rich Remer 6933ab4bf7 fix C type corresponding to f80 2024-08-12 00:25:16 -07:00
Andrew Kelley 54151428e5 std.crypto: better names for everything in utils
std.crypto has quite a few instances of breaking naming conventions.
This is the beginning of an effort to address that.

Deprecates `std.crypto.utils`.
2024-08-09 19:47:06 -07:00
Ryan Liptak 73a444766e langref: Make pointer_coerce_const_optional test less obfuscated
This test was originally introduced in 5f38d6e2e9, where it looked like this:

    test "cast *[1][*]const u8 to [*]const ?[*]const u8" {
        const window_name = [1][*]const u8{c"window name"};
        const x: [*]const ?[*]const u8 = &window_name;
        assert(mem.eql(u8, std.cstr.toSliceConst(x[0].?), "window name"));
    }

Over the years, this has become more and more obfuscated, to the point that the verbosity of the `expect` call overshadows the point of the example. This commit intends to update this test to match the spirit of the original version of the test, while shedding the obfuscation.
2024-07-29 16:07:12 -07:00
kj4tmp d484269543 improve @enumFromInt doc (#20354)
closes #19123
2024-07-21 02:41:43 -07:00
Alex Kladov 8267929742 langref: add example for errdefer |err| sytnax 2024-07-21 01:26:21 -07:00
ssmid 9232425b8f single pointer slice syntax added 2024-07-21 00:32:50 -07:00
Wooster 888708ec8a Sema: support pointer subtraction 2024-07-15 18:18:38 +00:00
Jora Troosh 13070448f5 std: fix typos (#20560) 2024-07-09 14:25:42 -07:00
Wayne Wu cb308ba3ac langref: correct test runner path 2024-06-27 19:37:44 +00:00
Ryan Liptak 0cef727e59 More precise error message for unencodable \u escapes
The surrogate code points U+D800 to U+DFFF are valid code points but are not Unicode scalar values. This commit makes the error message more accurately reflect what is actually allowed in `\u` escape sequences.

From https://www.unicode.org/versions/Unicode15.0.0/ch03.pdf:

> D71 High-surrogate code point: A Unicode code point in the range U+D800 to U+DBFF.
> D73 Low-surrogate code point: A Unicode code point in the range U+DC00 to U+DFFF.
>
> 3.9 Unicode Encoding Forms
> D76 Unicode scalar value: Any Unicode code point except high-surrogate and low-surrogate code points.

Related: #20270
2024-06-12 16:49:00 -04:00