1378 Commits

Author SHA1 Message Date
Andrew Kelley 571388a93d langref: use the word "namespace" instead of "container" 2026-04-19 10:38:01 -07:00
Sage Hane f0649e7709 langref: Clear up terminology used for top-level doc comments 2026-04-19 10:12:22 -07:00
David Senoner 21914c7c01 ziglibc: migrate tee linux syscall (#31911)
Add the Linux syscall wrapper for `tee`.

Migrate the `tee` syscall from musl libc to zig libc.

langref: note `ssize_t` and `isize`  are ABI compatible

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31911
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: David Senoner <seda18@rolmail.net>
Co-committed-by: David Senoner <seda18@rolmail.net>
2026-04-18 07:30:43 +02:00
Andrew Kelley 67a5b6e5e8 delete @cImport from the language
closes #20630
2026-04-15 17:43:53 -07:00
Andrew Kelley 24fdd5b7a4 Release 0.16.0 2026-04-13 11:19:17 -07:00
Mason Remaley 87fb7df257 Updates stack trace vs error return trace in more places 2026-04-12 04:01:30 -07:00
Mason Remaley ac207073f3 Reverts renaming of builtin.StackTrace -> ErrorReturnTrace
We can defer this change until the next time zig1 needs to be updated
2026-04-12 04:01:30 -07:00
Mason Remaley 94ff38af87 Separates error return traces from stack traces
Doesn't commit the changes to stage1, we can generate those at the end
once we're not making any more changes to it to avoid wasting storage.
2026-04-12 04:01:29 -07:00
Andrew Kelley 75457202d4 langref: deprecate @intFromFloat
and add documentation for new semantics of `@round`, `@ceil`, `@floor`,
and `@trunc`.

follows #30906
relates #31602
2026-04-11 08:36:39 -07:00
Kendall Condon 785fb1be11 fix several inconsistencies between parser and PEG
- PEG / Parser Changes

All the changes made here are to places where the PEG was more
permissive than the parser. Changes to the parser make it more
permissive and changes to the PEG make it more strict. When choosing
between these two options for discrepancies, I opted for the choice
that was more natural and increased code readability.

Changes to the Parser
* Tuple types can now be `inline` and `extern` (e.g. `extern struct`).
* Break labels are now only consumed if both the colon and identifier
  are present instead of failing if there is only a colon.
* Labeled blocks are no longer parsed in PrimaryExpr (so they are now
  allowed to have CurlySuffixExpr) as in the PEG.
* While expressions can now be grouped on the same line.
* Added distinction in error messages for "a multiline string literal"
  so places where only single string literals are allowed do not give
  "expected 'a string literal', found 'a string literal'".

Changes to the PEG
* Made it so extern functions cannot have a body
* Made it so ... can be only the last function argument
* Made it so many item pointers can't have bit alignment
* Made it so asm inputs / outputs can not be multiline string literals
* Added distinction between block-level statements and regular
  statements

-- Pointer Qualifier Order

The PEG allowed for duplicated qualifiers, which the parser did not.
The simplest fix for this was to make each be allowed zero or one times
which required giving them a order similar to how FnProto already
works. The chosen order is the same as used by zig fmt. The parser
still accepts them in any order similar to functions.

-- Backtracking

Made it so several places could not backtrack in the PEG. A common
pattern for this was (A / !A).

--- !ExprSuffix

Expressions ending with expressions now have !ExprSuffix after.
This change prevents expressions such as `if (a) T else U{}` being be
parsable as `(if (a) T else U){}`. It also stops some backtracking,
take for example:

`if (a) for (b) |c| d else |e| f`

It may seem at first that the else clause belongs to the `for`, however
it actually belongs to the `if` because for else-clauses cannot have a
payload. This is fixed by a new `KEYWORD_else / !KEYWORD_else`, however
this alone does not fix more complex cases such as:

`if (a) for (b) |c| d() else |e| f`

The PEG would first attempt to parse it as expected but fail due to the
new guard. It will then backtrack to

`if (a) (for (b) |c| d)() else |e| f`

which is surprising but avoids the new gaurd. So, !ExprSuffix is
required to disallow this type of backtracking.

--- !LabelableExpr

For identifiers, excluding labels is necessary despite ordered choice
due to pointer bit alignment. For example `*align(a : b: for (c) e) T`
could backtrack to `*align(a : b : (for (c) e)) T`.

--- !SinglePtrTypeStart

Prevents expressions like `break * break` which is parsed as
`break (*break)` backtracking to `(break) * (break)`

--- !BlockExpr

Prevents expressions like `test { {} = a; }` being backtracked to and
parsed as `test { ({} = a); }` (the parenthesis are just for
demonstration, that expression is not legal either)

--- !ExprStatement

In addition to splitting up block level statements, statements that are
also parsable as expressions are now part of ExprStatement to disallow
backtracking.
2026-03-25 17:29:56 -04:00
Karol Kosek 5861afb189 langref: make float mode fields lowercase
Reflects the change made in aab84a3dec.
2026-03-25 00:53:36 +01:00
Andrew Kelley 58890066d9 Merge pull request 'Sema: Support peer type resolution for floats and small integers' (#30921) from jayschwa/zig:ptr-small-int-and-floats into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30921
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-03-12 00:41:05 +01:00
Jay Petacat fcf64761d0 Sema: Support peer type resolution for floats and small integers
This builds on the changes in PR #30053 / commit 484cc15366.

Previously, peer type resolution would always result in a conflict for
fixed-width integer and float types. Now that small integer types can
coerce to floats, peer type resolution can take that into account. This
primarily benefits arithmetic with mixed float and integer operands. If
the integer operand can coerce to the float operand's type, it will do
so without requiring an explicit cast. If the integer type can't coerce,
there will be a compiler error; no float widening will occur. Explicit
casting will still be required to make it work.
2026-03-11 11:31:58 -06:00
Justus Klausecker be9b42d707 compiler: allow equality comparisons for packed unions
This was already possible in practice by just wrapping a packed union into
a packed struct. Now it's also possible without doing that.
2026-03-11 16:44:08 +01:00
FnControlOption c01b9b1ab5 langref: replace std.meta.Int with @Int 2026-03-11 02:37:05 +01:00
Meghan Denny bd5dc75068 std: remove GeneralPurposeAllocator alias 2026-03-11 01:55:49 +01:00
Matthew Lugg 34d780f4bb langref: update for language changes 2026-03-10 10:38:50 +00:00
Nils Juto 2da1370a7e sync CallModifier in langref with what's actually there 2026-02-27 13:50:12 +01:00
Ivan Agafonov 333055ced7 langref: specific expectEqual* functions instead of expect 2026-02-25 19:34:30 +01:00
Jay Petacat 97986184ca langref: Add table of largest integer types that can coerce to floats
Add vertical margin to the `.table-wrapper` class so that there's space
between the table and the test figures. It does not affect any of the
existing tables because the margin collapses with the adjacent `<p>`.
2026-01-26 23:52:30 +01:00
Alex Rønne Petersen b7a4756e1d langref: disable @cImport tests on NetBSD
https://github.com/Vexu/arocc/issues/960
2026-01-21 16:42:45 +01:00
Andrew Kelley c857fce05b langref: refine the underscore prefix section
more assertive yet less judgemental
2026-01-19 14:17:00 -08:00
Andrew Kelley e5dc5a6eb5 langref: refrain from underscore prefixes 2026-01-17 14:32:14 -08:00
Andrew Kelley 041701416b langref: all logic manages state 2026-01-17 13:57:14 -08:00
Matthew Lugg 01546e68cd compiler: handle switch rewrite review feedback 2026-01-11 14:37:28 +00:00
Justus Klausecker 5a376d97d4 langref: document new switch features
- switch on tagged union with runtime-captured tag
- switch on errors special cases
2026-01-11 11:37:17 +00:00
Jay Petacat 484cc15366 Sema: Allow small integer types to coerce to floats
If the float can store all possible values of the integer without
rounding, coercion is allowed. The integer's precision must be less than
or equal to the float's significand precision.

Closes #18614
2026-01-10 22:19:20 +01:00
Andrew Kelley 6a5bb3ede3 std: find a better home for the "preopens" concept 2026-01-08 05:06:31 +01:00
Andrew Kelley 77087f6f31 langref: update to new main API 2026-01-04 00:27:08 -08:00
Andrew Kelley 691afee786 langref: fix build failure 2025-12-23 22:15:12 -08:00
Alex Rønne Petersen 9373a963a1 langref: work around powerpc LLVM miscompilation in runtime_shrExact_overflow
https://github.com/ziglang/zig/issues/24304
2025-12-16 06:22:33 +01:00
meowjesty 755a3d957c langref: convert to unmanaged ArrayList in example 2025-11-23 18:32:05 +00:00
Ali Cheraghi dec1163fbb all: replace all @Type usages
Co-authored-by: Matthew Lugg <mlugg@mlugg.co.uk>
2025-11-22 22:42:38 +00:00
Matthew Lugg c5383173a0 compiler: replace @Type with individual type-creating builtins
The new builtins are:
* `@EnumLiteral`
* `@Int`
* `@Fn`
* `@Pointer`
* `@Tuple`
* `@Enum`
* `@Union`
* `@Struct`

Their usage is documented in the language reference.

There is no `@Array` because arrays can be created like this:

    if (sentinel) |s| [n:s]T else [n]T

There is also no `@Float`. Instead, `std.meta.Float` can serve this use
case if necessary.

There is no `@ErrorSet` and intentionally no way to achieve this.
Likewise, there is intentionally no way to reify tuples with comptime
fields, or function types with comptime parameters. These decisions
simplify the Zig language specification, and moreover make Zig code more
readable by discouraging overly complex metaprogramming.

Co-authored-by: Ali Cheraghi <alichraghi@proton.me>
Resolves: #10710
2025-11-22 22:42:37 +00:00
Nashwan Azhari af7dec94c6 docs: use custom error set in values.zig sample.
Signed-off-by: Nashwan Azhari <aznashwan@icloud.com>
2025-11-22 02:56:40 +02:00
Nashwan Azhari 153521279f docs: remove normal-doc comment interleaving bug note.
Signed-off-by: Nashwan Azhari <aznashwan@icloud.com>
2025-11-22 02:51:16 +02:00
Benjamin Jurk 4b5351bc0d update deprecated ArrayListUnmanaged usage (#25958) 2025-11-20 14:46:23 -08:00
Alex Rønne Petersen c82884542f langref: work around s390x LLVM compilation crash in test_defining_variadic_function
https://github.com/ziglang/zig/issues/21350#issuecomment-3543006475
2025-11-19 01:42:45 +01:00
Alex Rønne Petersen 4dd05b5a64 langref: work around s390x LLVM miscompilation in runtime_shrExact_overflow
https://github.com/ziglang/zig/issues/24304
2025-11-19 01:42:45 +01:00
Zirunis e1f12124fd Remove StringAlias because it implies the existence of a String type and is a redundant example anyway
Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
2025-11-09 14:05:09 +01:00
Zirunis 4dcc8a80a9 Simplified and unified sentence structure of the naming convention logic 2025-11-09 04:44:05 +01:00
Zirunis 07f50c0351 Update Style Guide to suggest TitleCase for Type aliases 2025-11-09 04:35:01 +01:00
Felipe Cardozo 0ec45050e0 docs: fix handle_error_with_catch_block typo 2025-10-26 05:37:28 +01:00
Ryan Liptak 2ab0ca13bb langref: Bump 0.15.1 to 0.15.2 2025-10-17 15:03:51 +02:00
Andrew Kelley d7d50496d9 langref: don't assume too much about pointer to packed struct field 2025-09-20 18:33:01 -07:00
Alex Rønne Petersen c547a05b65 langref: runtime_shrExact_overflow does not work as expected on LoongArch
https://github.com/ziglang/zig/issues/24304
2025-09-18 10:08:38 +02:00
rohlem 92223ad36f langref: mention union support of @fieldParentPtr 2025-09-17 20:07:30 -07:00
LukaTD 0b75a2a1b1 langref: added missing newlines to destructuring tuples example
langref: added missing newlines to destructuring tuples example
2025-09-10 02:31:20 +00:00
Andrew Kelley 6673b47685 frontend: vectors and arrays no longer support in-memory coercion
closes #25172
2025-09-07 17:29:36 -07:00
Andrew Kelley 4c01275664 Merge pull request #25163 from ziglang/packed-union-unused
forbid unused bits in packed unions
2025-09-06 12:08:31 -07:00