1392 Commits

Author SHA1 Message Date
abdessalem 340cf85faa add missing newline to destructuring mixed example 2026-06-11 05:37:18 +02:00
Nguyễn Gia Phong 09bb2315e2 langref: grammar: fix matching pointer of pointer
Fixes: bb83883acd ("langref: update for language changes")
2026-06-10 15:15:49 +02:00
Nguyễn Gia Phong 028028ede3 langref: grammar: remove redundant optional match
std.zig.AstSmith.pegSuffixOp is also fixed to match the grammar.
2026-06-10 15:15:49 +02:00
Ali Cheraghi d7d131c050 add @SpirvType builtin
Closes #35240
Fixes #35238
Fixes #35259

Supported types are:
- `OpTypeSampler`
- `OpTypeImage`
- `OpTypeSampledImage`
- `OpTypeRuntimeArray` with indexing and `.len` field

The SPIR-V backend is bit-rotted so behavior tests no longer pass (compiler crashes).
However I've verified the new added tests are passing.
2026-06-07 04:58:53 +02:00
Andrew Kelley 621844bde5 zig zen update
- rewordings
- "memory is a resource" goes without saying
- emphasize the final point
2026-06-04 17:02:49 -07:00
Isaac Freund 420c1994b3 langref: fix typo in PEG grammar 2026-06-03 13:34:50 +02:00
gemmaro cbc6266204 langref: Use syntax tag instead of backquotes 2026-05-31 09:15:44 +02:00
Krzysztof Wolicki 9e80795623 all: update to use new std.lang.Type definitions 2026-05-27 10:03:51 +01:00
Sertonix 7228dc0ef9 langref: fix compilation if usize is u32 2026-05-26 09:43:40 -07:00
mlugg 7eb79daffb Merge pull request 'std.builtin -> std.lang migration progress' (#32182) from compiler-std-lang into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/32182
2026-05-06 10:10:44 +02:00
Andrew Kelley ebff436985 langref: fix incorrect description of >> operation 2026-05-05 14:39:50 -07:00
Matthew Lugg e393962bc2 langref: use 'std.lang' instead of 'std.builtin' 2026-05-03 12:23:30 +01:00
Matthew Lugg bb83883acd langref: update for language changes 2026-04-30 09:03:58 +01:00
Matthew Lugg d764716cb5 compiler: remove capturing errdefer from the language
Resolves: https://github.com/ziglang/zig/issues/23734
2026-04-30 08:57:50 +01:00
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